From: Jesse Edelstein Date: 2007-11-22T02:04:24+09:00 Subject: Re: is there an nicer way for this expression? On Nov 21, 2007 10:35 AM, Wayne Magor wrote: > Not a stupid question at all. Many people want this in Ruby! > > Here's the solution (which should be standard in Ruby): > > class Object > def in?(an_array) > an_array.include?(self) > end > end > > > Then, your desire to have something like (foo.bar=1,2) would become: > > foo.bar.in?([1,2]) > Yeah, The Ruby Way also says that this should be part of the language. But I'm not sure it makes sense from an OO perspective - being "in" a container (or having a copy of oneself in that container) is not a property of an object, but rather a property of the container. It's convenient, but seems logically backwards.