๐ธNever
ๅฎ็พฉ
้่ฆ่ช้
Never is an uninhabited type, which means that it has no values. Or to put it another way, uninhabited types canโt be constructed. ... Consider a function declared to return an uninhabited type: Because uninhabited types donโt have any values, the function canโt return normally. ๐ NSHipster
Never is very useful for representing impossible code. Most people are familiar with it as the return type of functions like fatalError, but Never is also useful when working with generic classes. For example, a Result type might use Never for its Value to represent something that always errors or use Never for its Error to represent something that never errors. 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 โฆ ๐ SE-0215: Conform Never to Equatable and Hashable
้ตๅพชๅๅฎ
View
โญ๏ธ
ๅ่่ณๆ
Swift โฉ Standard Library โฉ Debugging & Reflection โฉ Never
Last updated