DAY #40 🎉 🎉🎉

Yesterday’s feature gets a little bit more advanced.

You can actually do matching with it!

1
2
3
4
5
6
7
enum MyEnum {
    case multiple(_ firstValue: String, _ secondValue: Int)
}
if case let MyEnum.multiple(_, theSecondValue) = .multiple("anything", 10) {
    // True no matter what `firstValue` is
    print(theSecondValue)
}

Code credit: Dustin @ Strega’s Gate

Originally published 09/25/2021 @ https://pittcsc.org/ Discord

Published here on 09/09/2022. Blog published date reflects the original date of publication.