KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Here is a method in Scala: def method1(arg: String*): List[String] = { try { new MyClass(new URL(arg(0))) .map(x => x.getRawString.toString) } catch { case e: Exception => e.printStackTrace() } } It complains on found : Unit [error] required: List[String] If I added an additional value so that: def method1(arg: String*): List[String] = { val result = try { new MyClass(new URL(arg(0))) .map(x => x.getRawString.toString) } catch { case e: Exception => e.printStackTrace() } result } it would say found : Any [error] required: List[String] which is odd -- isn't this the same as the first approach? Anyway, what is the Scala's standard way of dealing with this kind of situations -- returning a value from try { .. } catch { .. } ?
Tags (comma-separated)
Save Edits
Cancel