3 ms·
> But seriously, according to that link, it seems to me like the zero or empty type is more suitable. That's a bit different. The empty type is only suitable f
by saithound 2y ago
> But seriously, according to that link, it seems to me like the zero or empty type is more suitable.
That's a bit different. The empty type is only suitable for functions that never return (e.g. loop infinitely, crash the program). The type checker will prevent functions that have the empty type as a return type from returning.
- akdas 2y agoTo expand on this: the "unit" here represents the number of possible values that can be returned. The confusion is probably because "empty" can mean two things: - What's inside the returned value. That may be why the parent suggested empty for the unit type. But that's now what "unit" means in the common parlance. - How many possible values can be returned. Never returning means the function has zero possible return values.