From: Benoit Daloze Date: 2010-09-24T20:41:56+09:00 Subject: [ruby-core:32543] Re: [Ruby 1.9-Feature#3845][Open] "in" infix operator On 24 September 2010 09:28, "Martin J. D�rst" wrote: > > > On 2010/09/23 4:41, Johan Holmberg wrote: >> >> On Wed, Sep 22, 2010 at 1:48 AM, Yusuke ENDOH �wrote: > >> I also like the "x in foo" infix syntax. I would expect it to be a >> membership test, for example in the following situations: >> >> � � an_arr = [11,22,33] >> � � a_set = Set.new([11,22,33]) >> >> � � p (10 in an_arr) � � � � � �# false >> � � p (11 in an_arr) � � � � � �# true >> � � p (10 in a_set) � � � � � � # false >> � � p (11 in a_set) � � � � � � # true >> >> and probably similarly for other "collection type objects" too (I >> believe it works something like that in Python). > > Just my two cents, but I don't see why this case is important enough to > warrant deviating from the usual, object-oriented syntax (which may not > always look optimal, but is easy and straightforward). > > Regards, � �Martin. > > -- It is indeed some kind of syntactic sugar, and you are probably right to mention it, because maybe it should be implemented it with OO syntax before. The main problem being here to add a method to Object (which "pollute" almost all objects, and might be irrelevant/useless for some). This proposition avoid that, and I believe for this reason (and the beauty of it) it is somehow better (but unexpected for OO, and making a new particular case). Regards, B.D.