I was interested in performing system calls from Swift, and I found a resource that I had to modify somewhat. I imagine that the language has changed since that post was written. At any rate, here is the working code,
Tag Archives: Swift
Using Optional Values in Swift
Optional Values
Swift has a nil
keyword that is sort of like the None
keyword in Python; however, regular variables and constants cannot be nil
. In order for a variable to be nil
, it must be initialized as an optional. (Constants cannot be nil
or optional.) An optional is decalred by appending a question mark the variable type. For example, the two statements below are equivalent.