P
Peter Hickman
Ok this is probably not really functional programming but I was just
noodling about with Ruby when I thought "it would be quite nice if I
could do X". In this case X is as follows:
def X(text, action)
x.action
end
Quite clearly this does not actually work, otherwise I wouldn't be
asking. But is there some way in Ruby to do something like this?
noodling about with Ruby when I thought "it would be quite nice if I
could do X". In this case X is as follows:
def X(text, action)
x.action
end
=> "_bcd_f"X("abcedf", size) => 6
X("abcdef", upcase) => "ABCDEF"
X("abcdef", gsub(/[aeiouy]/, '_'))
Quite clearly this does not actually work, otherwise I wouldn't be
asking. But is there some way in Ruby to do something like this?