How would I impelement a function, in ruby, such as the following?
change_me! (val)
update:
What I set out to do was this:
def change_me! (val)
val = val.chop while val.end_with? '#' or val.end_with? '/'
end
This just ended up with….
change_me! 'test#///' => "test#///"
You’re thinking about this the wrong way around. While it may be possible to do this in Ruby, it would be overly complicated. The proper way to do this would be:
Which, of course, varies depending on the class of what you want to change. The point is that, by convention, the methods with ‘!’ affect the class instance on which they’re called.
So…
Hope this helps a bit..