On Jun 9, 2007, at 10:34 AM, Logan Capaldo wrote:
> On Sat, Jun 09, 2007 at 11:20:16PM +0900, charon wrote:
>> Hi,
>> definitely _NOT_ a bug
>> read this plz: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ 
>> ruby-talk/168231
> Well, it not being a bug is arguable. ;) It's definitely not an
> unintentional bug.

No, no argument at all.  There is however conflicting information in  
the Pickaxe that describes Range#member? as having different behavior  
that #include? (although ri Range#member? shows that #=== #include?  
and #member? are the same).

If the OP wants behavior like the Pickaxe (now incorrectly)  
describes, you can always do:

class Range
   def member? item
     any? {|x| item == x}
   end
end

irb> ('A'..'IV').member?('J')
=> true
irb> (1..10).include?(5.5)
=> true
irb> (1..10).member?(5.5)
=> false

Although the performance for testing a "big" Range and an item close  
to the #end might be undesirable.

Of course, that does beg the question of whether #include? (#===) or  
#member? is used by libraries.  Is there a common way to note which  
of a set of names is used when there are aliases?  It seems like if  
one were to treat #begin, #include?, and #end as a set, then #first,  
#member?, and #last would be a similar set (currently all aliases)  
and a redefinition of #member? could be reasonably expected to  
redefine #last to be the final value returned by #each.  For a Range  
where #exclude_end? is true, #last != #end would be justifiable.

-Rob

Rob Biedenharn		http://agileconsultingllc.com
Rob / AgileConsultingLLC.com