# @State of optional: type spelling Optional\<Int\> is not the same as Int?

**URL:** <https://forums.swift.org/t/state-of-optional-type-spelling-optional-int-is-not-the-same-as-int/62780>\
**Category:** Using Swift\
**Created:** [January 25, 2023, 3:36am UTC](https://forums.swift.org/t/state-of-optional-type-spelling-optional-int-is-not-the-same-as-int/62780 "2023-01-25T03:36:47Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![DevAndArtist](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/devandartist/32/287_2.png) [@DevAndArtist](https://forums.swift.org/u/DevAndArtist)\
**Post date:** [January 26, 2023, 6:44am UTC](https://forums.swift.org/t/state-of-optional-type-spelling-optional-int-is-not-the-same-as-int/62780/7 "2023-01-26T06:44:29Z")

</div>

It's not an issue with `State` it looks a compiler issue.

```swift
struct S {
  var a: Int?
  var b: Optional<Int>

  init() {
    // error: Return from initializer without initializing all stored properties
  }
}

```

`a` will automatically be initialized with `nil` as a convenience feature, but `b` will not!

Related topics:

- [Pitch: Remove default initialization of optional bindings](https://forums.swift.org/t/pitch-remove-default-initialization-of-optional-bindings/6961)
- [Pre-pitch: remove the implicit initialization of Optional variables](https://forums.swift.org/t/pre-pitch-remove-the-implicit-initialization-of-optional-variables/52300)

@Slava_Pestov @jrose maybe we should aim to remove this for Swift 6? The example of confusion about the effects it causes for `State` is a fair motivation. On top of that explicit `Optional` isn't treaded the same by the compiler anyways.

Edit: 🤦‍♂️ I meant to reply in this thread [SwiftUI @State PW exact same code different result if another optional is added!? :=(](https://forums.swift.org/t/swiftui-state-pw-exact-same-code-different-result-if-another-optional-is-added/62789) but accidentally replied here and just realized that @mayoff already explained the puzzle.

---

_[View the full topic](https://forums.swift.org/t/state-of-optional-type-spelling-optional-int-is-not-the-same-as-int/62780)._
