Ruby 代码异常求助。

codecook · January 30, 2013 · Last by iBachue replied at January 30, 2013 · 1782 hits

实例:

class Module
    def const_missing(name)
        match = /^ASCII_FOR_([A-Z]|[a-z])$/.match(name.to_s)
        if match
            return match[1][0]
        else
            raise NoMethodError
        end
    end
end
puts ASCII_FOR_A
puts ASCII_FOR_z

结果: A z

教程上说是输出 65 和 122?为什么错误了?谢谢

另外请教如何排版啊??TKS

p RUBY_VERSION

是 ruby 版本问题

排版,M 键,看帮助

1.8 出数字 1.9 出字符

You need to Sign in before reply, if you don't have an account, please Sign up first.