I have the following method:
scala> def method_with_default(x: String = "default") = {x + "!"}
method_with_default: (x: String)java.lang.String
scala> method_with_default()
res5: java.lang.String = default!
scala> method_with_default("value")
res6: java.lang.String = value!
I'm trying to achieve the same with a val, but I get a syntax error, like this:
(with no default value, this one compiles ok)
scala> val function_with_default = (x: String) => {x + "!"}
function_with_default: String => java.lang.String = <function1>
(but I couldn't get this one to compile...)
scala> val function_with_default = (x: String = "default") => {x + "!"}
<console>:1: error: ')' expected but '=' found.
val function_with_default = (x: String = "default") => {x + "!"}
^
any idea?