> On Mar 31, 2016, at 5:04 PM, Charles Srstka via swift-evolution
> <[email protected]> wrote:
>
> What I often do is use ?? to provide a default (usually false).
>
> if myList?.isEmpty ?? false {
> print(“Empty”)
> } else {
> print(“Not empty”)
> }
That’s what I get for writing a reply quickly; in this particular case the
default should probably be true, since you probably want to treat a nil list as
empty.
if myList?.isEmpty ?? true {
print(“Empty”)
} else {
print(“Not empty”)
}
Charles
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution