Tuesday 3 September 2013

Catch exception in Scala constructor

Catch exception in Scala constructor

What is the Scala equivalent of this Java code, where
someMethodThatMightThrowException is defined elsewhere?
class MyClass {
String a;
String b;
MyClass() {
try {
this.a = someMethodThatMightThrowException();
this.b = someMethodThatMightThrowException();
} finally {
System.out.println("Done");
}
}
}

No comments:

Post a Comment