List comprehension in Ruby

Posted by Readonly on Stack Overflow See other posts from Stack Overflow or by Readonly
Published on 2008-11-21T22:27:45Z Indexed on 2010/05/02 17:08 UTC
Read the original article Hit count: 108

Filed under:

To do the equivalent of Python list comprehensions, I'm doing the following:

some_array.select{|x| x % 2 == 0 }.collect{|x| x * 3}

Is there a better way to do this...perhaps with one method call?

© Stack Overflow or respective owner

Related posts about ruby