score:1

Accepted answer

you can use for-comprehensions to work with option but you can't use it for objects that don't have at least one defined foreach, map or flatmap. in your case, if params is returning options then...

for(
  input1 <- params get "input1"
  input2 <- params get "input2"
 ){
   //do stuff
 }

wherein this will not run if both input and input2 are not none.

if you don't want to short circuit the control logic and you want there to be sane defaults for option returns, then a better way is just to do

 myfunction(params getorelse ("input1", "default1"), params getorelse ("input2", 42))

where you're explicitly providing the defaults and passing them into a function call.


Related Query

More Query from same tag