I want to create a filter and apply it to an array or hash. For example:
def isodd(i) i % 2 == 1 end
I want to be able to use it like this:
x = [1,2,3,4] puts x.select(isodd) x.delete_if(isodd) puts x
It seems like it should be straightforward, but I can't figure out what I need to do to get it to work.
ruby
brianegge Aug 28 '09 at 15:01 2009-08-28 15:01
source share