Skip to content

Instantly share code, notes, and snippets.

@alexgriff
Created June 10, 2016 13:04
Show Gist options
  • Save alexgriff/4d0a65499944f9d6f37fccc37c2b5598 to your computer and use it in GitHub Desktop.
Save alexgriff/4d0a65499944f9d6f37fccc37c2b5598 to your computer and use it in GitHub Desktop.
array = [[1],[2],[3]]
# 1 will it error? / name that error!
# 1a.
array.first + 1
# 1b.
array.first.first + 2
# 1c.
array.first.first.first + 3
# 2 will it error? / name that error!
array.first.map do |element|
element * 4
end
# 3 will it error? / name that error!
array.each do |element|
element.each do |sub_element|
puts sub_element.first
end
end
# 4 will it error? / name that error!
# 4a.
array.flatten.reverse.uniq.compact.reverse
# 4b.
array.flatten.uniq.compact.pop.reverse
# 5 will it error? / name that error!
array.each do |element|
element + [element]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment