14
Rubyで定数を使い始めました。Ruby:定数を反復する
私は
Constants.each do |c|
#do something with each one
end
をしたいと思ったが、それは
undefined method ‘each’ for Constants::module
言う....
module Constants
C1 = "foo"
C2 = "bar"
end
を持っているが反復の良い方法はあります定数のリストを通して?
この質問のために有用なリンク:http://stackoverflow.com/questions/2309255/how-do-i-get-constants-defined-by-rubys-module-class-via-reflection。 –