Retrieve part of a string with the [] method, using a range. : char range « String « Ruby






Retrieve part of a string with the [] method, using a range.


thoreau = "qwerqwerqwerqwerqwer"

puts thoreau[7..9] 

 








Related examples in the same category

1.starting at the end of the string using negative numbers, get the second to last character through the eighth to last
2.iterate over all the characters using a block
3.Range indexes are negative