Skip to content

Instantly share code, notes, and snippets.

@tyleramos
Created October 11, 2018 20:30
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 tyleramos/08c5c60302de640804c66086b7f5a58b to your computer and use it in GitHub Desktop.
Save tyleramos/08c5c60302de640804c66086b7f5a58b to your computer and use it in GitHub Desktop.
Debugging BE (Ruby) - arrays
a = [2, 3, 4]
b = %w[Cats Frogs Dogs]
new_array = []
a.each do |item|
new_item = b[item].downcase
item = b + item
new_array.push(itom)
end
# I want to see a new_array that looks like this:
# ['4 cats', '6 frogs', '8 dogs']
# Why does the above code blow up, and what can we do to fix it?
# Can you write this in a better way?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment