Skip to content

Instantly share code, notes, and snippets.

@threewordphrase
Created September 13, 2016 22:59
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 threewordphrase/7113e4bcf8bbc6a5fa6725973fa7c345 to your computer and use it in GitHub Desktop.
Save threewordphrase/7113e4bcf8bbc6a5fa6725973fa7c345 to your computer and use it in GitHub Desktop.
array = [
1,
2,
[3, 4, 5, [6, 7, 8]],
[9, 10, 11, 12],
13
]
@capture = []
def process_array(array)
array.each do |item|
if item.class == Fixnum
@capture.push item
elsif item.class == Array
process_array(item)
else
puts 'Item is not an integer or array!'
end
end
end
process_array(array)
puts @capture.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment