Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You can't do that. It would require a language change, to make try/catch blocks expressions.


You can sort of do this in Groovy.

  def val = {try { 1 } catch(ex) { 2 }}.call()
  assert(1 == val)


Heh, I didn't think so. ;)




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: