3 ms·
Ruby does allow you to pass a one-parameter function as the argument to `map`: irb(main):001:0> ["foo", "bar"].map(&:reverse) => ["oof", "rab"] Not precis
by drewbug01 3y ago
Ruby does allow you to pass a one-parameter function as the argument to `map`:
irb(main):001:0> ["foo", "bar"].map(&:reverse)
=> ["oof", "rab"]
Not precisely the same as what you've outlined, of course, but perhaps useful nonetheless.
- inopinatus 3y agoFun fact, the arity of functions generated by Symbol#to_proc is not 1 but -2 (that is, additional arguments are passed through as well), so we can write stuff like module MissionControl #... [Proc, Method, Binding, UnboundMethod].each_with_object(self, &:include) end if one were so inclined.
- drewbug01 3y agoHuh - truly did not know about _negative_ arity in Ruby, and what that actually means. I learned something today, thank you!