1οΈβ£ μ μ
- wrapping λ κ°μ΄λ κ°μ absenceλ₯Ό λνλ
@frozen
enum Optional<Wrapped>
2οΈβ£ μ€λͺ
- λ κ°μ§ κ²½μ°κ° μλ μ΄κ±°ν
Optional.none
μ nil
μμμ κ°μ
Optional.some(Wrapped)
μ wrapping λ κ°μ μ μ₯ν¨
let number: Int? = Optional.some(42)
let noNumber: Int? = Optional.none
print(noNumber == nil)
β¨ Optional Binding
- λ³μμ΄λ¦μ΄ κ°κ² λ°μΈλ©ν μ
=
μλ΅κ°λ₯
let number: Int? = 42
guard let number else {
break;
}
μΆμ²π
πApple Docs: Optional