Last active
May 13, 2016 00:49
-
-
Save rdammkoehler/12ca9f092c67652bbd34f859ac1f034a to your computer and use it in GitHub Desktop.
Not what you thought you'd get
This file contains hidden or 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
| a = [ { :items => [{ 'item' => 'junk' },{ 'item' => 'junk' },{ 'item' => 'junk' }] }] | |
| # => [{:items=>[{"item"=>"junk"}, {"item"=>"junk"}, {"item"=>"junk"}]}] | |
| a[0][:items].count # => 3 | |
| d = [] # => [] | |
| d.push a[0][:items] # => [[{"item"=>"junk"}, {"item"=>"junk"}, {"item"=>"junk"}]] | |
| d.count # => 1, not 3 | |
| d.push a[0][:items] # => [[{"item"=>"junk"}, {"item"=>"junk"}, {"item"=>"junk"}], [{"item"=>"junk"}, {"item"=>"junk"}, {"item"=>"junk"}]] | |
| d.count # => 2, not 6 | |
| d.flatten.count # => 6 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment