3 ms·
Of course, one of the common knocks on Ruby is that naively referring to a function executes it, and to pass functions around avoiding list.map { |i| process
by dylan 18y ago
Of course, one of the common knocks on Ruby is that naively referring to a function executes it, and to pass functions around avoiding
list.map { |i| process i }
one must write
list.map &method(:process)
or, as the Rails guys have done [1], open up Symbol#to_proc so that
list.map &:process
works. This will be part of core Ruby in 1.9, but last I heard it's slow [2].
[1] http://github.com/rails/rails/tree/master/activesupport/lib/active_support/core_ext/symbol.rb http://github.com/rails/rails/tree/master/activesupport/lib/...
[2] http://www.ruby-forum.com/topic/161089 http://www.ruby-forum.com/topic/161089