i’d like to now if their is a simpler way to do that :
IN_NEWS=@h[‘IN_NEWS’]
because here i do have to know their is a key of name “IN_NEWS”
want i want is to affet the value of all the @h[‘key_name’] to the
variable key_name ???
(as far as i remember well it’s possible in php then i think this is
also possible in ruby ))))
Une bévue wrote:
also possible in ruby ))))
Thinking out loud…
hash.each_key{|k|
eval("#{k}=hash[#{k}]")
}
There may be a better way, though…
On 8/10/06, Alex Y. [email protected] wrote:
hash.each_key{|k|
eval(“#{k}=hash[#{k}]”)
}
hash.each_pair {|k,v|
Object.const_set(k, v)
}
martin
Martin DeMello [email protected] wrote:
hash.each_pair {|k,v|
Object.const_set(k, v)
}
fine thanxs to both of them !!!
On Thu, 10 Aug 2006, [ISO-8859-1] Une bévue wrote:
(as far as i remember well it’s possible in php then i think this is
also possible in ruby ))))
define_method(‘key_name’){ @h[‘key_name’ }
-a
[email protected] wrote:
define_method(‘key_name’){ @h[‘key_name’ }
ok fine, may it’s the best ?