I have a hash of an array of arrays. The array is indexed by the hash (that is the way I am reading this):
[
{"name":"G18","data": [["X301",141],["x7901",57],["x2100",142],["x90",58]]},
{"name":"G19","data": [["M16",141],["M203",57],["M29S",142]]},
{"name":"G20","data": [["X301",141],["x7901",57],["x2100",142],["x90",58]]}
]
I want to select the hashes that contain the array G18, and return only the data.
I tried searching for answer, but I haven't found anything like this yet.
hfor whichh.key("name") #=> trueandh["name"] === "Gi8" #=> truecan be zero or more than one."G18"is not an array and you presumably mean that you want to return the value of:data. If you assign a variable to your array (arr = [{...) you could say that you "wish to returnh[:data]for the element ofhofarrfor whichh[:name] == "G18"istrue. That assumes there is exactly one such hashhhaving that property. If zero or more than one could have that property, the statement would have to be adjusted according.