Defining a new logical operator in Ruby
问题 Very much an idle day-dream this but is it possible with some neat meta-programming trick to define a new logical operator in Ruby? I'd like to define a but operator. For example, if I want to do something if x but not y is true I have to write something like: if x and not y But I would like to write if x but not y It should work exactly the same as and but would be down to the programmer to use sensibly to increase the legibility of code. 回答1: Without editing the Ruby parser and sources and