Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这就是我目前所拥有的。但是,?e显示字符的字符代码而e不是变量 e。如何解决?谢谢。
?e
e
('a'..'z').each {|e| puts ?e}
如果你真的想输出它们:
(?a..?z).each { |c| puts c.ord }
如果您只需要 26 个数字的数组。
(?a..?z).map(&:ord)
尝试这个
('a'..'z').each {|e| puts e.ord.to_s}
甚至:
puts ('a'.ord..'z'.ord).to_a