Skip to content

Instantly share code, notes, and snippets.

@cheald
Created July 10, 2015 17:16
Show Gist options
  • Save cheald/d88f37a5b9f0e5cfcc8e to your computer and use it in GitHub Desktop.
Save cheald/d88f37a5b9f0e5cfcc8e to your computer and use it in GitHub Desktop.
2.2.2 :002 > [1, 2, 3].each_with_object(0).with_index {|num, obj, index| p [num, obj, index] }
[[1, 0], 0, nil]
[[2, 0], 1, nil]
[[3, 0], 2, nil]
=> 0
2.2.2 :003 > [1, 2, 3].each_with_object(0).with_index {|(num, obj), index| p [num, obj, index] }
[1, 0, 0]
[2, 0, 1]
[3, 0, 2]
=> 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment