# Where I can read about motivation of use .none while switching optional enumerations

**URL:** <https://forums.swift.org/t/where-i-can-read-about-motivation-of-use-none-while-switching-optional-enumerations/37038>\
**Category:** Using Swift\
**Created:** [May 30, 2020, 11:08am UTC](https://forums.swift.org/t/where-i-can-read-about-motivation-of-use-none-while-switching-optional-enumerations/37038 "2020-05-30T11:08:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlexSedykh](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@AlexSedykh](https://forums.swift.org/u/AlexSedykh)\
**Post date:** [May 30, 2020, 11:08am UTC](https://forums.swift.org/t/where-i-can-read-about-motivation-of-use-none-while-switching-optional-enumerations/37038/1 "2020-05-30T11:08:20Z")

</div>

Hello. I discovered that if we are switching optional enumeration we have case .none.

```
enum Temperature {
    case cold, warm
}

func checkTemp(temperature: Temperature?) {
    switch temperature {
    case .cold: break
    case .warm: break
    case .none: break
    }
}

```

Please give me the link to proposal of that feature.

---

<div class="post-metadata">

**Author:** ![cukr](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/cukr/32/889_2.png) [@cukr](https://forums.swift.org/u/cukr)\
**Post date:** [May 30, 2020, 11:39am UTC](https://forums.swift.org/t/where-i-can-read-about-motivation-of-use-none-while-switching-optional-enumerations/37038/2 "2020-05-30T11:39:45Z")

</div>

There are many layers to unravel here

1. all these things were there before swift was even open source, so there are no proposals for these
2. `Temperature?` is a short way to write `Optional<Temperature>`
3. Optional is an enum with two cases, `some` and `none` [swift/Optional.swift at main · apple/swift · GitHub](https://github.com/apple/swift/blob/master/stdlib/public/core/Optional.swift#L122)
4. when you have a static member `Foo.bar` that returns `Foo` and you're in a context that expect instance of `Foo` you can just write `.bar` (for example `let x: Int = .zero` )
5. if you have value of type `Foo` you can use it in places that expect `Foo?` without explicitly writing `.some` (for example `let x: Int? = 123` )

What you're doing is switching on two enumerations, one nested inside another. We can write it more explicitly to make it more clear where `none` is coming from

```swift
func checkTemp(temperature: Optional<Temperature>) {
    switch temperature {
    case Optional.some(Temperature.cold): break
    case Optional.some(Temperature.warm): break
    case Optional.none: break
    }
}

```
