On 25 Mar 2011, at 16:07, Robert Klemme wrote: >> >> Is there a way to define infix operators in Ruby, as I quite like this one? :) > > There is no way to define new operators other than hacking the > interpreter. IMHO it's a bad idea to do this just for a minor > nuisance. Well, yeah, I won't be hacking the interpreter for this :) Just wondering. Is there somewhere I could suggest `+?` as an operator for Ruby 2? It was only an off the cuff remark but I quite like it :) > > I don't understand what's wrong with > > HEADERS = [] > %w{BLAH BLAH_BLAH BLAHHH}.each do |var| > x = ENV[var] and HEADERS.concat(x.split(/:+/)) > end > > Nice short concise and yet readable. > I totally agree, there's nothing wrong with that, and out of the suggestions given I think that's the one I like best (which makes me feel better for labouring the point:) It's only that, as I said, Ruby usually has some really nice shortcuts that don't seem like shortcuts, just natural looking. A bit like having to define getters and setters, there's nothing wrong with it, but `attr_accessor :var` is really nice, as is `||=` and it's ilk. Wouldn't this be quite nice, for instance? [a,b,c,d].reduce(:+?) That's all. Regards,