Re: "num in [1,2,3,4]" in a cool way?
On 20 Aug 2008, at 22:32, Iñaki Baz Castillo wrote:
Hi, AFAIK in Ruby the only (or the "coolest") way to do something as:
if num in [1,2,3,4]
is by doing:
if [1,2,3,4].index(num)
Is it? any other "cooler" way? Thanks.
Well not saying this is actually a good idea, but...
class Object
def in(collection)
collection.include? self
end
end
if num.in [1,2,3,4]
...
end
.
Relevant Pages
- Merry Xmas Turdy
... because he knows you have been saying bad things about Australia in the ... It has been a very wet summer so far, and much cooler than normal too. ... (sci.geo.geology) - Re: Kwikfit Air Conditioning - views
... they were saying: ... degrees would be a mental amount to expect it to make it cooler. ... Suppose it depends how you compare it - if it was a hot summer's day and ... (uk.rec.cars.misc) - Re: Kwikfit Air Conditioning - views
... they were saying: ... degrees would be a mental amount to expect it to make it cooler. ... Suppose it depends how you compare it - if it was a hot summer's day and ... (uk.rec.cars.misc) - Re: "num in [1,2,3,4]" in a cool way?
... if num in ... any other "cooler" way? ... Technical Blaag at: http://blog.majesticseacreature.com | Non-tech ... (comp.lang.ruby) - Re: "num in [1,2,3,4]" in a cool way?
... if num in ... any other "cooler" way? ... Robert might chime in with an inject version, so I won't do one of those. ... (comp.lang.ruby) |
|