From: Martin DeMello Date: 2006-12-04T01:17:15+09:00 Subject: Re: How to get the values for Excel constants at once On 12/3/06, chen li wrote: > > --- Martin DeMello wrote: > > > Use const_get - it's a method defined on Module. > > > > Excel_Const.constants.sort.each{|i| > > puts "The value of Excel_Const::#{i} is > > "+Excel_Const.const_get(i) > > } > > Thank you very much. BTW it doesn't work when + is > there so I change the code into the following: Oops - yes, + assumes that all the constants are strings. Should have been +Excel_Const.const_get(i).to_s You could also just inline it into the string: puts "The value of Excel_Const::#{i} is #{Excel_Const.const_get(i)}" since #{} automatically calls to_s on the return value of the block. martin