Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否有一种编程语言可以让我们编写如下内容:
a => b
计算含义?(其中a和b是布尔值)
a
b
我能找到的最接近的是 Scala:
a <= b
但它看起来与“蕴涵”的实际含义完全不同。
所以获胜者是 Scala:
implicit class BooleanMagic(val b: Boolean) extends AnyVal { def ==>(other: =>Boolean) = !b || other }
多亏了这一点:
> true ==> false res0: Boolean = false > false ==> (throw new Exception("I'm the president")) res1: Boolean = true