String#tr
allows c1-c2
as a shorthand notation for a range of characters:
a-z
expands toabcdefghijklmnopqrstuvwxyz
b-z
expands tobcdefghijklmnopqrstuvwxyz
b-za
isb-z
followed by a singlea
, i.e.bcdefghijklmnopqrstuvwxyza
Finally s.tr!('a-z', 'b-za')
replaces each letter by the next one in the alphabet using this mapping:
from_str: abcdefghijklmnopqrstuvwxyz
to_str: bcdefghijklmnopqrstuvwxyza
solved What is za and what is next