String#succは、辞書順ではない

ぼけっとしてて気づいてなかった。

"999"の辞書順で次の文字列は、"999a"や"9990"であって、"1000"ではない。

["999", "1000"].max
 => "999"
["999", "999".succ].max
 => "999"

後者は直感的に変だと思うんだけど。

ひとまず、適当に辞書順になりそうな感じのメソッドを定義して逃げることに。

class String
  def succc
    case self[-1]
    when "9"
      self + "0"
    when "z"
      self + "a"
    when "Z"
      self + "A"
    else
      self.succ
    end
  end

  def nexxt
    self.succc
  end
end

cとxが一つずつ多い。