ふと気になったので&&とnotのみの条件判定と、xorとどちらが速いか計測してみた。 それぞれ100万回ループさせています。 rubyのバージョンは1.8.7 詳細は以下のとおり。 &&とnot ソース 1000000.times {|i| if true == !false && false == !true p 'hoge' end } 結果 time ruby xor.rb > /dev/null real 0m2.924s user 0m2.152s sys 0m0.756s xor ソース 1000000.times {|i| if (true == true) ^ (false == false) p 'hoge' end } 結果 time ruby xor.rb > /dev/null real 0m2.726s user 0m1.953s sys 0m0.744s 適当に

