Having,
def test(args: Any*) = args.size
I would call it an empty argument list depending on the condition, but avoid if / else.
I came up with this solution:
test(List("one").filter( _ => condition) : _*)
Is there a better way than this?
For more context, I play with Play 2.0 scala and get the following:
user => Redirect(routes.Application.index).withSession("username" -> user._1).withCookies(
List(Cookie("rememberme", Crypto.sign(user._1) + "-" + user._1)).filter(_ => user._3) : _*)
where user._3is rembemberme boolean.
I would not call Session or call it with an empty argument list (not to create an instance of Cookie) if memme is false, in a scala way.
Thank.
source
share