the bellow code :
scala> class A {
| def hi = "Hello from A"
| override def toString = getClass.getName
| }
defined class A
scala> val a = new A()
a: A = A
scala> a.toString
res10: String = A
scala> println(s"${a.toString}")
$line31.$read$$iw$$iw$A
It is printing ok when using a.toString
expression, not when using println(s"${a.toString}")
. The problem is getClass.getName
. In other cases it works nice.
Thanks in advance for any help
scala> class A { override def toString = getClass.getName } defined class A scala> val a = new A() a: A = $sess.cmd0$A scala> a.toString res2: String = "$sess.cmd0$A" scala> println(s"""${a.toString}""") $sess.cmd0$A
– Pentosan