I already knew about syntactic shortcuts like:
[“1”, “2”, “3”].map(&:to_i)
But today I learned I could do something like:
[“1”, “2”, “3”].map(&method(:Integer))
Actually, this example is a bit contrived. What I really wanted to do was this accursed thing:
ENV[“NUMERICAL_ID”]&.then(&:Integer)
Which will either be `nil` (if the env var is not defined) or an Integer (if it is defined and can be converted safely). Anything else raises an exception.
No point to this. Just something cursed I almost did, but backed away from.