Skip to content

Instantly share code, notes, and snippets.

@judofyr
Created August 4, 2009 23:22
Show Gist options
  • Save judofyr/162368 to your computer and use it in GitHub Desktop.
Save judofyr/162368 to your computer and use it in GitHub Desktop.
## Taken from The Ruby Programming Language, page 110.
# The following simple Ruby program demostrates a flip-flop. It reads a
# text file line-by-line and prints any lines that contains the text "TODO".
# It then continues printing lines until it reads a blank line.
ARGF.each do |line | # For each line of standard in or of named files
print line if line=~/TODO/..line=~/^$/ # Print lines when flip-flop is true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment