dimanche 17 juillet 2016

How do I open Try value in scala and add its values by mapping them

I have some function tat returns Try of some case class and I want to check if something came back in the Try I want to use its value and add it to a list, my code looks like this:

val resultLines = csvDataReader.iteratorWithHeaders.map(row => {

val someTry = fonctionThatReturnsTryOfSomeCaseClass(someArgument)

row ++ "key" -> someTry.map(a => a.someVal).getOrElse("")

}

my desired output is that to have resultLines be full with the rows, but the resultLines comes out as empty iterator...

it dosent really work, I get this error:

Error during generated code invocation: com.intellij.debugger.engine.evaluation.EvaluateException: Method threw 'java.lang.IllegalAccessError' exception.

Aucun commentaire:

Enregistrer un commentaire