by java-man · 5y ago · 0 comments
class B extends UnionBase;
public UnionBase someMethod();
furthermore, UnionBase might have isA() and isB() if need be.
So, strictly speaking, your statement is incorrect.
public (A | B) someMethod();
in Java.I also want my tools to know what's being returned, as well as my compiler.
Usually these are the languages with more focus on type safety, like OCaml, Haskell and Rust.