# Let's fix \`if let\` syntax

**URL:** <https://forums.swift.org/t/lets-fix-if-let-syntax/48188>\
**Category:** Pitches\
**Created:** [May 11, 2021, 6:18pm UTC](https://forums.swift.org/t/lets-fix-if-let-syntax/48188 "2021-05-11T18:18:49Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![David\_Catmull](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/david_catmull/32/1007_2.png) [@David\_Catmull](https://forums.swift.org/u/David_Catmull)\
**Post date:** [May 11, 2021, 8:04pm UTC](https://forums.swift.org/t/lets-fix-if-let-syntax/48188/12 "2021-05-11T20:04:26Z")

</div>

> [@stevex](#):
>
> ```swift
> function plop(foo: Foo) {
> const x = foo.bar.length; // error, Foo.bar? is possibly undefined
> if (foo.bar != null) {
> const y = foo.bar.length; // this is fine
> }
> }
> 
> ```

Personally I'm not fond of this approach. It is convenient, but I find it really weird that merely performing a comparison would change the type of a variable from optional to non-optional.

---

_[View the full topic](https://forums.swift.org/t/lets-fix-if-let-syntax/48188)._
