This seems to be a pretty good example of a "built-in" function that I
can't really see a practical use for... why does it need to be standard?
Why is it named so cryptically? When would you ever want to use it?
This seems to be a pretty good example of a "built-in" function that I
can't really see a practical use for... why does it need to be standard?
Why is it named so cryptically? When would you ever want to use it?
--
Posted via http://www.ruby-forum.com/.
It's named after the unix program 'tr' with parameter '-s' as in squeeze.
Jan
···
On Friday 04 January 2008 22:44:48 Jordan Cooper wrote:
This seems to be a pretty good example of a "built-in" function that I
can't really see a practical use for... why does it need to be standard?
Why is it named so cryptically? When would you ever want to use it?
str.tr_s(from_str, to_str) => new_str
Processes a copy of _str_ as described under +String#tr+, then
removes duplicate characters in regions that were affected by the
translation.
"hello".tr_s('l', 'r') #=> "hero"
"hello".tr_s('el', '*') #=> "h*o"
"hello".tr_s('el', 'hx') #=> "hhxo"
It's named after the unix program 'tr' with parameter '-s' as in
squeeze.
Jan
That makes more sense, thank you. I'm still not sure if it's justified,
in my head; but I guess that may be because of my C# background, where
it's encouraged to err on the side of too verbose as opposed to too
cryptic.
Unfortunately I still don't see a practical use for the thing though.