Reputation: 901
I have the following hash:
hash = {"A" =>[1,2,3,4]}
Within that hash is a key "A"
with the value of [1,2,3,4]
.
Is there a possible way to access a single element within my array using the key-value pair?
Example (...yes I know this isn't legal Ruby):
hash["A",0] => 1
Or have the ability to see if the array included a value with the key-value pair?
hash["A".include? 4] => true
Upvotes: 1
Views: 72
Reputation: 16022
Did you mean this?:
hash = {"A" =>[1,2,3,4]}
hash["A"][0] #=> 1
hash["A"].include? 4 #=> true
Upvotes: 6