Easy question, but couldn't find it in the doc.
How do I slice a string or array from n until forever?
>> 'Austin'[1..3]
=> "ust"
>> 'Austin'[1..]
SyntaxError: compile error
(irb):2: syntax error, unexpected ']'
from (irb):2
Easy question, but couldn't find it in the doc.
How do I slice a string or array from n until forever?
>> 'Austin'[1..3]
=> "ust"
>> 'Austin'[1..]
SyntaxError: compile error
(irb):2: syntax error, unexpected ']'
from (irb):2
Pretty elegant using the endless range introduced in Ruby 2.6:
string = 'Austin'
string[1..] # => ustin
Hope that's handy for someone. Cuts a couple of characters from the best approach until now, and will be very readable once endless ranges are regularly adopted.