Sam Smoot
12/28/2006 10:16:00 PM
The filter_evens() example is not very ruby-ish. (As I interpret it
anyways.) I might write it like this:
class Fixnum
def even?
self % 2 == 0
end
def odd?
not self.even?
end
end
Then instead of a filter_evens() method, I would just:
list.select { |n| n.even? }
Or even shorter:
list.select &:even?
....if you have 'facets/symbol/to_proc' or 'active_support' loaded.