Experimenting with Scala... I'm trying to define something analogous to the "@" hack in PHP (which means, ignore any exception in the following statement).
I managed to get a definition that works:
def ignoreException(f: () => Unit) = { try { f(); } catch { case e: Exception => println("exception ignored: " + e); } }
And use it like this:
ignoreException( () => { someExceptionThrowingCodeHere() } );
Now here is my question... Is there anyway I can simplify the usage and get rid of the () =>, and maybe even the brackets?
Ultimately I'd like the usage to be something like this:
`@` { someExceptionThrowingCodeHere(); }