-
-
Save regedarek/084a5967011df6e91b36 to your computer and use it in GitHub Desktop.
Find in array of hashes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
items = [ | |
{ | |
:condition => "NewItem", | |
:seller_sku => "bsgnpoprod_142829029X_41", | |
:asin => "142829029X", | |
:quantity => "1" | |
}, | |
{ | |
:condition => "UsedGood", | |
:seller_sku => "bsgnpoprod_142829029X_42", | |
:asin => "142829029X", | |
:quantity => "1" | |
}, | |
{ | |
:condition => "UsedGood", | |
:seller_sku => "bsgnpoprod_142829029X_43", | |
:asin => "142829029X", | |
:quantity => "1" | |
}, | |
{ | |
:condition => "UsedGood", | |
:seller_sku => "bsgnpoprod_1403975078_44", | |
:asin => "1403975078", | |
:quantity => "1" | |
} | |
] |
Author
regedarek
commented
Aug 1, 2012
>> items.flatten.count {|h| h[:asin] == '1403975078'}
1
>> items.flatten.count {|h| h[:asin] == '142829029X'}
3
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment