Never as a universal "bottom" subtype An uninhabited type can be seen as a subtype of any other type--if evaluating an expression never produces a value, it doesn't matter what the type of that expression is. If this were supported by the compiler, it would enable some potentially useful things, for instance using a nonreturning function directly as a parameter to a higher-order function that expects a result (array.filter(fatalError)) or allowing a subclass to override a method and covariantly return Never. This can be considered as a separate proposal. Moving from @noreturn to -> Never is not a regression here, since the compiler does not allow an arbitrary conversion from @noreturn (T...) -> U to (T...) -> V today. The most important use case, a nonreturning function in void context, will still work by the existing (T...) -> U to (T...) -> Void subtyping rule.
https://github.com/apple/swift-evolution/blob/master/proposals/0102-noreturn-bottom-type.md#never-as-a-universal-bottom-subtype?:
は x ? y : z
の省略形で x ?: z
== x ? x : z
的に考えたら自然な演算子だけど( Nullable を Boolean
のように使えればだけど)、 x ? y : z
を廃止して ?:
だけ採用したからよくわからない記法になってしまった感が。if (x) y else z
でやれというのもわからんでもないけど。 (edited)