Sherwin Yu Sherwin Yu - 1 year ago 89
Ruby Question

Ruby idiom for substring from index until end of string

Just wondering if there's a Ruby idiom for extracting a substring from an index until the end of the string. I know of

which works by passing in a range object to the
method but it's a little clunky. In python, for example, you could write
which would implicitly get you the rest of the string.


s = "hello world"
s[6..-1] # <-- "world"

Is there anything nicer than

Answer Source

I think it isn't.

It seems that Range is better way to do it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download