I have some code block like this:
object EntryPoint extends App {
val arr = ArrayBuffer(1, 2, 3)
doFirst(arr)
def doFirst(a: ArrayBuffer[Int]) = {
doSecond(s"$a")
}
def doSecond(
x: => String = ""
) = {
x match {
case s: String => println(s"This is string: $s")
case _ => println(x.getClass.getName)
}
}
}
Output: This is string: ArrayBuffer(1, 2, 3)
Why x evaluated like a string if in debugger i see lambda with 3 arguments?
Is it because every call x is x.apply() ?
xin your doSecond method, x is evaluated, and you're passing the toString representation of your ArrayBuffer.EntryPoint$$Lambdawith internal fieldarg. I'm interesting in possibility to get thatargvalue manually