4 ms·
all_users.select(&:is_active).map(&:name).sort isn't standard Ruby; it will (currently) only work in Rails. It's standard in 1.9, and making it work in 1.8 is
by Freaky 18y ago
all_users.select(&:is_active).map(&:name).sort
isn't standard Ruby; it will (currently) only work in Rails.
It's standard in 1.9, and making it work in 1.8 is all of 3 lines:
class Symbol
def to_proc() proc {|obj, *args| obj.__send__(self, *args) } end
end
Or if you've got facets:
require 'facets/symbol/to_proc'
- mhartl 18y agoIt's standard in 1.9 That's why I said "(currently)". From the official Ruby homepage: The current stable version is 1.8.7. making it work in 1.8 is all of 3 lines I agree, but this still makes it not standard Ruby. The article should have mentioned this.