ff10 ff10 - 3 months ago 8x
Swift Question

What does the "Some" keyword in the Xcode console mean?

Printing the description of an object yields lldb to use the keyword "Some" in front of the object's description (here I po an optional string):

(lldb) po someString
- Some: "Hello Jupiter"

What is the meaning of this keyword; why is it there?


Optional is an enum with two cases, none, and some(wrapped):

enum Optional<Wrapped> {
    case Some(Wrapped)
    case None

As you can see, the Optional either has a value of Some, with an associated value (the value the Optional wraps), or None. Optional.None is actually the meaning of nil.

In this case, the debugger is telling you that someString is an Optional<String> (a.k.a. String?), which has a value of Optional.Some("Hello Jupiter"). It's not Optional.None, thus it's not nil.