From: Dan Doel Date: 2003-08-11T08:25:25+09:00 Subject: Re: Ruby and OOP-design (question of an old "procedural person" ;) Rudolf Polzer wrote: >Scripsit ille �Brian Candler� : > > >>On Mon, Aug 11, 2003 at 02:02:33AM +0900, dblack@superlink.net wrote: >> >> >>>>Does ruby not have exclusive or? I can't remember at the moment. If it >>>>did, I think the top is the same >>>>as: >>>> >>>>unless a.nil? ^ b.nil? >>>> >>>>Which is still somewhat unclear, I agree. >>>> >>>> >>>I, however, no long agree with myself :-) I just forgot about ^. >>> >>> >>However ^ is overloaded, so although it works when comparing false/true with >>false/true, it doesn't with other things; especially since it doubles up as >>a bitwise numeric operator too. >> >> > >BTW: why do all C-like languages lack the ^^ operator (boolean XOR)? > I'm no expert, but I suspect it's because ^ and ^^ do the same thing. The big reason for & and && is that && is lazy, while & evaluates all its arguments. Otherwise you could always use & and overload it for use with integers and booleans. ^ always has to know the values of both arguments, so it can never be lazy, so there's no point in having two, except in Ruby's case where ^ can be overloaded, and ^^ would be useful to coerce both arguments to booleans. - Dan