line[line.index("k")] : index « String « Ruby






line[line.index("k")]


line = "A horse! a horse! my kingdom for a horse!"

line[line.index("k")] # => 107
line[line.index("k")].chr # => "k"

 








Related examples in the same category

1.The index method returns the index location of a matching substring.
2.Index and last index a pattern
3.Replace first vowel with an asterisk