4 ms·
The Haskell solution is to require a type annotation if the type is ambiguous. Of course, Java provides no way to do that.
by Filligree 10y ago
The Haskell solution is to require a type annotation if the type is ambiguous.
Of course, Java provides no way to do that.
- Manishearth 10y agoWell, I presume `String something = getSomething(); Object s = (Object)something;` would be okay. Note that in Rust we don't have inheritance (not exactly the same kind, at least), so it's rare where a statically typed value can be referred to with a different type. So there are still annoyances in Java with this approach that Rust wouldn't have.