The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

wgillett (11) [Avatar] Offline
The break statement implementation is conceptually nice, but I think could use some tuning. For reference, here it is:

def break = new RuntimeException("break exception")

Then later:

catch { case _ => }

Unfortunately this catch statement will catch *any* exception that happens in the try block, not just the RuntimeException created by the break function. Instead we should throw and catch a custom exception class. I understand the desire to keep the code simple for the reader, but this is not a good pattern to encourage. At the very least, it's worth noting this potential problem briefly.