From: Skye Weir-Mathews Date: 2007-05-10T02:59:37+09:00 Subject: using variables for the hash name and key name I'm trying to call a value from a hash using variables for both the hash name and the key I'm trying to call So I've got a hash like this hash_name = { "key_name_1" => "value_name_1", "key_name_2" => "value_name_2", "key_name_3" => "value_name_3", } and earlier in the script I have two variables: @hash_name_var, which looks like it's equal to hash_name (this statement is true, 'hash_name' == @hash_name_var) @key_name_var, which looks like it's equal to key_name_1 (this statement is true, 'key_name_1' == @key_name_var) So, I'm trying to get the value out of the hash with @hash_name_var[@key_name_var] but this doesn't work However, hash_name[@key_name_var] does work, so since 'hash_name' == @hash_name_var it makes me think I need to find a way to make: @hash_name_var == hash_name instead of @hash_name_var == 'hash_name' -- Posted via http://www.ruby-forum.com/.