Created
January 9, 2015 20:32
-
-
Save avdi/d9d92640e570fcba2988 to your computer and use it in GitHub Desktop.
Behold, the null enumerator.
This file contains hidden or 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
e = loop | |
e # => #<Enumerator: main:loop> | |
e.next # => nil | |
e.next # => nil | |
e.peek # => nil | |
e.size # => Infinity | |
e.rewind | |
e.next # => nil |
[5].cycle
Nice.
@AaronLasseigne Ooh, very nice.
@avdi That's interesting. It's a shame #with_object
doesn't use use #next_values
. I wonder if Ruby would accept a patch for it…
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Interestingly, @Peeja, at least
next_values
agrees with you: