Since Groovy 1.8.3 we can use the implies() method on Boolean types. The implies() method implements a logical implication. This means that if we have two Boolean variables A and B, that if A is true, then B is true. So if A is true then it is implied B is true as well. If A is false then B can be either true or false. We could rewrite the implication as !A or B.
def a = true def b = true assert a.implies(b) assert !(a.implies(false)) assert a.implies(b) == ((!a).or(b)) assert true.implies(true) assert false.implies(true) assert false.implies(false) assert !true.implies(false)
(Code written with Groovy 2.0.4)
3 comments:
Than or Then? Great post man :)
@Anonymous: thank you for pointing out the errors. I have changed than to then.
モンクレールは世界中でもっとも人気なブランド品です!デザインは独特性でモダンとクラシックを持っている魅力があります!!今、ちょうど秋冬になるんですから、おしゃれなモンクレール ジャケットは今間違いなし選択です。完売必至!人気満点のトンクサンダル!それに素足に合わせてエレガントなスタイルを楽しめる!全体的にバランスが良いです。履くと急にファッション感が溢れています。セレブ感も高いです。
Post a Comment