I'd like to get a substring from a string from position N to the 开发者_StackOverflow中文版end of the string.
What's the way to do it in Ruby?
Just slice the string like:
string[N..-1]
or you can use the size : str[N,str.size-1]
As of Ruby 2.6, you can use endless range syntax for this:
string[N..]
where N is the start index. (No need to specify a -1
for the end index.)
精彩评论