null - Does anybody know the rationale behind "(nil < 0) == true" and "(nil <= 0) == true" in Swift? -
i think swift constructed modern language, however, there 1 thing puzzle me, , rationale having (nil <= 0) == true , (nil < 0) == true.
here more cases:

anyway, return true nil < 0 seems go against whole optional concept, 1 of argument avoiding default number initialization "0". "0" special again.
anybody has explanation swift decided have (nil <= 0) , (nil < 0) return true.
optionals comparable, can sorted, example. rules simple:
- any 2 optionals nil compare equal.
- if 1 of optionals nil , other not, nil less non-nil.
- if both optionals not nil, unwrapped values compared.
as consequence, nil equals nil, , nil less non-nil optional.
it has nothing value 0 assigned. assign -1000, or +100, or whatever like, , same result.
Comments
Post a Comment