Comment on Java 21 makes me actually like Java again

<- View Parent
aloso@programming.dev ⁨1⁩ ⁨year⁩ ago

It’s not possible to instantiate or assign, which is more like a never type than a unit

Actually, this is because void is not a type, it is just a keyword, that is allowed only instead of the return type.

If it were a bottom type, that would mean that a method returning void must diverge, which is simply not true.

Also, even if it were a bottom type, it would be possible to write an “unreachable” method

void foo(void bottom) {
    return bottom;
}

But it is not, because void isn’t a bottom type, it’s no type at all.

source
Sort:hotnewtop