1 / 4
Jun 2004

while (l = gets.chomp.to_i) != 42
	puts l
end
  • created

    Jun '04
  • last reply

    Dec '11
  • 3

    replies

  • 1.4k

    views

  • 4

    users

2 years later
3 months later

[quote="robertosoares"]

print while gets != "42"

[/quote]

robertosoares, just small bug-fix:

print while gets != "42\n"

or

print while gets.chop != "42"
4 years later

print until/42/===gets
or more Ruby-fan-style:
/^42$/=~$<.read;puts$`