Next value of a string : succ « String « Ruby






Next value of a string


'89999'.succ                           # => "90000"
'nzzzz'.succ                           # => "oaaaa"

'Zzz'.succ                             # => "AAaa"

'z'.succ                               # => "aa"
'aa'.succ                              # =>  "ab"
'zz'.succ                              # => "aaa"

'AA'.succ                              # =>  "AB"
'AZ'.succ                              # =>  "BA"
'ZZ'.succ                              # => "AAA"
'aZ'.succ                              # =>  "bA"
'Zz'.succ                              # => "AAa"

'foo19'.succ                           # => "foo20"
'foo99'.succ                           # => "fop00"
'99'.succ                              # => "100"
'9Z99'.succ                            # => "10A00"

'10-99'.succ                           # => "11-00"

'a-a'.succ                             # => "a-b"
'z-z'.succ                             # => "aa-a"
'Hello!'.succ                          # => "Hellp!"
%q{'zz'}.succ                          # => "'aaa'"
%q{z'zz'}.succ                         # => "aa'aa'"
'$$$$'.succ                            # => "$$$%"

 








Related examples in the same category

1.Produce successive string
2.non letter string successor