How can I simulate Haskell's “Either a b” in Java

后端 未结 14 2318
梦毁少年i
梦毁少年i 2020-12-07 22:40

How can I write a typesafe Java method that returns either something of class a or something of class b? For example:

public ... either(boolean b) {
  if (b)         


        
14条回答
提交回复
热议问题