Just wondering if there’s a Ruby idiom for extracting a substring from an index until the end of the string. I know of str[index..-1] which works by passing in a range object to the String‘s [] method but it’s a little clunky. In python, for example, you could write str[index:] which would implicitly get you the rest of the string.
Example:
s = "hello world"
s[6..-1] # <-- "world"
Is there anything nicer than s[6..-1]?
I think it isn’t.
It seems that
Rangeis better way to do it.