본문 바로가기

Programming/Swift

Swift Optionals

However there is another data type in Swift called Optional, whose default value is a null value ( nil ). You can use optional when you want a variable or constant contain no value in it. An optional type may contain a value or absent a value (a null value).

www.programiz.com/swift-programming/optionals

 

Swift Optionals: How to Use them (With Examples)

In the previous article, we learned about different data types available in Swift and also noticed variable or constant declared of those types contains a default value. Example: let someValue = Int() print(someValue) When you run the program, the output w

www.programiz.com

nil은 값이 없는 상태.

0도 아닌 ""도 아닌 아무것도 없다는 상태 나타냄.

 

eastroot1590.tistory.com/entry/Swift-nil이-될-수-있는-변수-optional

 

Swift - nil이 될 수 있는 변수 optional

개요 swift의 특징 중 하나인 optional에 대해 알아보자. 문법만 보면 너무나 생소한 문법이라서 처음에는 많이 놀랐는데, 알고보면 익숙한 기능을 간결하게 작성할 수 있도록 해주는 문법이라는 것

eastroot1590.tistory.com

 

'Programming > Swift' 카테고리의 다른 글

mutating  (0) 2020.10.13
Properties and Methods  (0) 2020.10.13
Enumeration (열거형: list)  (0) 2020.10.13
상수 constant  (0) 2020.10.13
Functions with Parameters  (0) 2020.10.12