Re: [swift-users] Optional chaining and String properties

2016-08-01 Thread Stephen Schaub via swift-users
rary/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Expressions.html#//apple_ref/swift/grammar/optional-chaining-expression > > On Mon, Aug 1, 2016 at 8:17 PM, Stephen Schaub via swift-users > wrote: > > I understand that the String.characters property is not o

Re: [swift-users] Optional chaining and String properties

2016-08-01 Thread Stephen Schaub via swift-users
ally, >> `s?.characters.count` works because `s.characters` isn’t Optional. You only >> use ? on properties that are Optional. >> >> On Aug 1, 2016, at 10:26, Stephen Schaub via swift-users < >> swift-users@swift.org> wrote: >> >> With optional chaining,

Re: [swift-users] Optional chaining and String properties

2016-08-01 Thread Stephen Schaub via swift-users
“Linking Multiple Levels of Chaining". Basically, > `s?.characters.count` works because `s.characters` isn’t Optional. You only > use ? on properties that are Optional. > > On Aug 1, 2016, at 10:26, Stephen Schaub via swift-users < > swift-users@swift.org> wrote: > > With

[swift-users] Optional chaining and String properties

2016-08-01 Thread Stephen Schaub via swift-users
With optional chaining, if I have a Swift variable var s: String? s might contain nil, or a String wrapped in an Optional. So, I tried this to get its length: let count = s?.characters?.count ?? 0 However, the compiler wants this: let count = s?.characters.count ?? 0 or this: