Skip to content

Instantly share code, notes, and snippets.

@samuraijane
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samuraijane/6ab26d6fee32f9c2460e to your computer and use it in GitHub Desktop.
Save samuraijane/6ab26d6fee32f9c2460e to your computer and use it in GitHub Desktop.
You can write using a block or write the code on one line when nesting maps. This code shows you how to do both.
#Code with block
$myvariable= imgarray.map do |layouts|
layouts[ 'layouts' ].map do |layout_name|
layout_name['layout_name']
end
end
#Code on one line
$myvariable= (imgarray.map{ |layouts| (layouts[ 'layouts' ]).map{ |layout_name| (layout_name[ 'layout_name' ]) }} )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment