# Definite initialization feature

**URL:** <https://forums.swift.org/t/definite-initialization-feature/63825>\
**Category:** Using Swift\
**Created:** [March 20, 2023, 11:11am UTC](https://forums.swift.org/t/definite-initialization-feature/63825 "2023-03-20T11:11:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kilian](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/kilian/32/28955_2.png) [@Kilian](https://forums.swift.org/u/Kilian)\
**Post date:** [March 20, 2023, 11:11am UTC](https://forums.swift.org/t/definite-initialization-feature/63825/1 "2023-03-20T11:11:55Z")

</div>

I don't quite understand this definite initialization feature from [this pitch](https://forums.swift.org/t/pitch-if-and-switch-expressions/61149). Can somebody explain?

```swift
let bullet: String
if isRoot && (count == 0 || !willExpand) { bullet = "" }
else if count == 0 { bullet = "- " }
else if maxDepth <= 0 { bullet = "▹ " }
else { bullet = "▿ " }

```

---

<div class="post-metadata">

**Author:** ![tera](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tera/32/38201_2.png) [@tera](https://forums.swift.org/u/tera)\
**Post date:** [March 20, 2023, 11:30am UTC](https://forums.swift.org/t/definite-initialization-feature/63825/2 "2023-03-20T11:30:40Z")

</div>

If you forget "else" compiler will complain that "bullet" is not initialised. In other words compiler gives you a guarantee that "let bullet: String" is definitely initialised at some point (and definitely before it is used). Contrary to the case where you have, say, "var bullet: String!" _(strictly speaking in that case the bullet is also initialised (to nil) which may not be expected by the following code)_.
