# 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:** 45

<div class="post-metadata">

**Author:** ![aerobounce](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/aerobounce/32/14175_2.png) [@aerobounce](https://forums.swift.org/u/aerobounce)\
**Post date:** [May 12, 2021, 8:18am UTC](https://forums.swift.org/t/lets-fix-if-let-syntax/48188/45 "2021-05-12T08:18:56Z")

</div>

Isn't this more of

- Shorthand syntactic sugar for ' **variable shadowing**'

rather than `if let`, `guard let` or `case let` etc?

Because I mean, type casting `if let v = v as? OtherType { ... }` is not included in this discussion, is it?  
Also as mentioned by @ensan-hcl , if a value is chained, it would not work.

* * *

Keyword `unwrap` sounds natural to me as it is already used in stdlib:

- [Apple Developer Documentation](https://developer.apple.com/documentation/swift/optional/1641793-unsafelyunwrapped)

Something like this?  
If new syntax must be used with existing `if` keywords:

```swift
let optionalValue: Int?

if unwrapped optionalValue { ... } // <- Past tense sounds more natural, I guess
// or
if unwrap optionalValue { ... }

guard unwrapped optionalValue else { ... }
// or
guard unwrap optionalValue { ... }

```

However, it would be also nice if it can be used standalone:

```swift
let optionalValue: Int?

unwrap optionalValue { ... } // In this context present tense sounds natural
unwrap optionalValue else { ... } // awkward?

```

* * *

Similar thread:

- [[Pitch] Introduce `let-else` syntax as alternative for single expression `guard-let-else`](https://forums.swift.org/t/pitch-introduce-let-else-syntax-as-alternative-for-single-expression-guard-let-else/46989)

---

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