matz / zetabits.com (Yukihiro Matsumoto) wrote:
> Hi,
> 
> In message "[ruby-talk:15863] Experimental "in" operator for collections"
>     on 01/05/28, Stefan Matthias Aust <sma / 3plus4.de> writes:
> 
> |Just to test how Ruby would feel like, I modified the system to allow 
> |
> |  object in array
> |
> |and
> |
> |  object not in array
> |
> |as new kinds of expressions.  Internally, Ruby uses "include?" (in the
> |second case inverted as with "not") to perform the test.  IMHO it
> |nicely fits into the language.
> 
> I like this idea.  My only concern left is whether "include?" is a
> proper method for "in" operator or not.

Personally, I feel it's moving in the wrong direction.  I like the idea of 
another method being added (the reversed include?) instead of a new operator 
being introduced.  If we're going to make in an operator, it should at the 
least be redefineable like most of the other operators.  E.g., the default 
implementation would be something like:

module DefaultIn
	def in(container)
		container.each {|val|
			return true if self == val
		}
		false
	end
end

-- 
 Brian Fundakowski Feldman           \  FreeBSD: The Power to Serve!  /
 green / FreeBSD.org                    `------------------------------'