From: "Peña, Botp" Date: 2007-10-11T10:36:24+09:00 Subject: Re: will #in? be in ruby2? (was Re: Finding shared elements between to arrays.) From: Alex Gutteridge # Daniel's point (I think) is that this pollutes the top # level Object with a property which for many (most?) # Objects is never relevant. If arggh, i wish we could measure that "pollution". (sometimes, i even includes Trans's facets gem of extensions :) My addition of it is not about polluting, it's about me expressing my thoughts well in a program. I thought in? would include just a very small helpful code. # you never put it an Object into a collection then # the idea of being 'in' something makes no sense. well i thought that all objects in ruby can be put into a container, so i reckon #in? (like #include?) would be very handy too. I use it many times. # On the other hand it is always an intrinsic part # of an Enumerable implementing class (by definition # a collection of Objects) that you may often need to # know whether it 'includes' a specified object. no problem there. # I'm not sure why the includes construct rocks your brain # though. Both read very logically to me (as a native # English speaker admittedly): # # a3 = a1.select { |e| a2.include?(e) } # # reads as: 'select' from a1 those e where a2 'includes' e. # # a3 = a1.select { |e| e.in? a2} # # reads as: 'select' from a1 those e where e is 'in' a2. i'm reading it again, and i still find the second one much better to read, it's straightforward and you can read it fast. try reading it like in math or in symbolic logic, {|e| e.in? a} read: "e such that e is in a" whereas {|e| a.in? e} read: "e such that a includes e" suddenly, my point of (object) reference changes from e to a and from left to right. which is kind of weird to me assumming I were to right it in a technical report. I would use include? and in? like the ff, {|a| a.include? e} {|e| e.in? a} note the similarity and difference. clear reading left to right. Clearly, if there's a place for include?, there is too for in?. # That said I always write this as: # a3 = a1 & a2 that was just a simple example (and besides, i'm not even sure they are the same) to show difference bw include? and in?. kind regards -botp