3 ms·
You wouldn't use a named Ruby method for something like this. You'd typically use a Proc or block. [1,2,3].map{ |x| x * 2 } or if you wanted to reuse the
by carbon8 16y ago
You wouldn't use a named Ruby method for something like this. You'd typically use a Proc or block.
[1,2,3].map{ |x| x * 2 }
or if you wanted to reuse the block for other things
transform = lambda { |x| x * 2 }
[1,2,3].map(&transform)
- djacobs 16y agoExactly, but there should be an easier syntax that declaring a lambda for each algorithm I want to map over.
- deleted 16y ago[deleted]