I would like an idiomatic way to print an error from inside of a loop
and break from that loop in a single statement. I thought I could do
something simple with “and” but it doesn’t work with Kernel#puts due to
#puts returning nil.
e.g.
loop do
rc = do_some_work
STDERR.puts “Work failed” and break unless ok?(rc)
end
I can get that example to work if I use “or” for flow control rather
than “and” but it doesn’t read right to me.
STDERR.puts “Work failed” or break unless ok?(rc) # yuck
Any suggestions for a nice, clean, idiomatic way of accomplishing the
above?
cr