Hacker News new | ask | show | jobs
by Filligree 3376 days ago
The Haskell solution is to require a type annotation if the type is ambiguous.

Of course, Java provides no way to do that.

1 comments

Well, 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.