From: dblack@... Date: 2007-06-26T06:16:51+09:00 Subject: Re: .include?/.within? and English-thinking brains HI -- On Tue, 26 Jun 2007, Michael Judge wrote: > In English, it's clearer to ask, "Is Maggie one of the guests?" -- rather > than the awkward, "Does the guests include Maggie?" Well, you're stacking the deck a bit to make it sound awkward ("Does the guests") :-) Anyway, we have both; it all depends what you're trying to say. > So why in Ruby, do we write, "list.include? scalar" -- when we often mean, > "scalar.within? list" ?! Because Ruby isn't English; we use both in English anyway; and Ruby doesn't have #within? :-) > The solution: > > module Comparable > def within?(list) > list.include? self > end > end There's been discussion of this in the past; have a look for #in? proposed by Hal a while back. David -- * Books: RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) RUBY FOR RAILS (http://www.manning.com/black) * Ruby/Rails training & consulting: Ruby Power and Light, LLC (http://www.rubypal.com)