0

是否有一种编程语言可以让我们编写如下内容:

a => b

计算含义?(其中ab是布尔值)

我能找到的最接近的是 Scala:

a <= b

但它看起来与“蕴涵”的实际含义完全不同。

4

1 回答 1

0

所以获胜者是 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
于 2014-07-04T08:23:35.760 回答