实例:
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