How to turn a Ruby method into a block?
pointfree, ruby, styles
Solution
You can use Object#method(method_name):
filenames.map(&File.method(:size))
Problem
Is there a way to simplify the following code? filenames is a list of filenames (strings), e.g. ["foo.txt", "bar.c", "baz.yaml"] ``` filenames.map { |f| File.size(f) } ``` Is there any way to turn "File.size" into a proc or block? For methods on existing objects, I can do `&:method`. Is there something analogous for module level methods?