lundi 23 mai 2016

How to access hash value using a variable in ruby?

I am wondering,Is their any way i can access hash value using a variable. Example:

nested_array = ["temp"]["temp1"]
temp_hash = {"temp"=>{"temp1"=>54}}

Here i want to access 54.I know it can be accessed like x["temp"]["temp1"].But,I want to access it using variable nested_array over temp_hash hash.

Aucun commentaire:

Enregistrer un commentaire