-
-
Save andymatuschak/475072 to your computer and use it in GitHub Desktop.
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
# Suppose I want to the user to enter names one at a time, until the user enters a blank line, | |
# then tell each name that they're awesome. | |
# Yeah, I don't have really a better way of doing that, and that bothers me. I'd do: | |
a = [] | |
until (str = gets.chomp?).empty? | |
a << str | |
end | |
# The key thing that keeps you from using a standard HOM is that you don't know the | |
# number of elements you're going to have off the bat. | |
# Generators are a pattern for dealing with this: http://en.wikipedia.org/wiki/Generator_(computer_science) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment