http://ujihisa.nowa.jp/entry/1801356369
すべてがメッセージ呼び出しと解釈した場合の解の1つ
module OOnize def not; !self end def and(other) self && other end def or(other) self || other end def then(other) !self || other end end [ TrueClass, FalseClass ].map {|i| i.__send__(:include, OOnize) } class Proc def if(bool) call if bool end def unless(bool) call unless bool end end
とすると、こう書ける。
a = 3 b = 4 lambda { p 'OK' }.if a.odd?.and b.odd?.not lambda { p 'OK' }.unless a.even?.or b.even?.not
しかし、全然うれしくないのが欠点。