B
Benjamin Fowl
Is there a way of checking whether a group of keys exist within a hash.
For example you have the following hash
example = {
rofile => { :name => "John",
:username =>
"johnny_bravo"},
:example1 => { :var1 => "test",
:var2 => "test2" }
}
now all you want is a function that can be passed an array of required
keys
eg req = [:name, :username, :var1]
this array can contain any number of required keys is not always just
keys that are in either the profile or example1 sub hashes.
I've looked at using the .keys method to compare keys but that requires
me to specify where to look in the hash.
Any help much apreciated
For example you have the following hash
example = {
:username =>
"johnny_bravo"},
:example1 => { :var1 => "test",
:var2 => "test2" }
}
now all you want is a function that can be passed an array of required
keys
eg req = [:name, :username, :var1]
this array can contain any number of required keys is not always just
keys that are in either the profile or example1 sub hashes.
I've looked at using the .keys method to compare keys but that requires
me to specify where to look in the hash.
Any help much apreciated