Skip to main content
retag
Link
hlovdal
  • 28.6k
  • 11
  • 103
  • 179
Source Link
readonly
  • 358.4k
  • 109
  • 207
  • 207

List comprehension in Ruby

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?