I ran into this behavior which surprised me. Essentially, if I create "the same" XML Elem
from two different XML literals, they fail to equal one another. The unique thing here is that I am using a Boolean
in one and a String
in the other.
scala> import scala.xml._
import scala.xml._
scala> val t: Boolean = true
t: Boolean = true
scala> val fromBoolean: Elem = <b>{t}</b>
fromBoolean: scala.xml.Elem = <b>true</b>
scala> val fromString = <b>true</b>
fromString: scala.xml.Elem = <b>true</b>
scala> fromString == fromBoolean
res0: Boolean = false
Is this the expected behavior?
It seems that Scala is storing the underlying type and a Boolean doesn't strictly equal a String.
Is this correct interpretation, and can anyone explain what exactly is going on here? I couldn't find a way to inspect the underlying type within the two nodes. If I look at the children they just appear to be Node
s.
scala> fromString.child(0)
res1: scala.xml.Node = true
scala> fromBoolean.child(0)
res2: scala.xml.Node = true