Created
February 13, 2012 20:53
-
-
Save jstotz/1820315 to your computer and use it in GitHub Desktop.
Ruby Enumerable#zip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum1 = [:a, :b, :c] | |
enum2 = [1, 2, 3] | |
enum1.zip(enum2) do |x, y| | |
puts "#{x} -> #{y}" | |
end | |
# Output: | |
# a -> 1 | |
# b -> 2 | |
# c -> 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment