Scala variable argument list with call-by-name possible?

You have to use zero-argument functions instead. If you want, you can

implicit def byname_to_noarg[A](a: => A) = () => a

and then

def foo(s: (() => Any)*) = s.foreach(a => println(a()))

scala> foo("fish", Some(7), {println("This still happens first"); true })
This still happens first
fish
Some(7)
true

Leave a Comment