I am new to ruby and recently started reading the Seven languages in Seven Weeks
and at the page 35, there is practice question on
For the string “Hello, Ruby,” ﬁnd the index of the word “Ruby.”
How do it in Ruby? Need some guidance ..
from the docs:
index(regexp [, offset]) → fixnum or nil Returns the index of the first occurrence of the given substring or pattern (regexp) in str. Returns nil if not found. If the second parameter is present, it specifies the position in the string to begin the search.
so for your predicament: