Optional array vs. empty array in Swift

I’m going to make the opposite case from Yordi – an empty array just as clearly says “this Person has no children”, and will save you a ton of hassle. children.isEmpty is an easy check for the existence of kids, and you won’t ever have to unwrap or worry about an unexpected nil.

Also, as a note, declaring something as optional doesn’t mean it takes zero space – it’s the .None case of an Optional<Array<Person>>.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)