【发布时间】:2011-07-15 20:10:25
【问题描述】:
我刚刚开始在 Ruby 中使用常量。
我有
module Constants
C1 = "foo"
C2 = "bar"
end
我想做
Constants.each do |c|
#do something with each one
end
但它说
undefined method ‘each’ for Constants::module
....
有没有一种很好的方法来遍历常量列表?
【问题讨论】:
-
这个问题的有用链接:stackoverflow.com/questions/2309255/….
标签: ruby