Cay Horstmann
unread,Oct 1, 2011, 11:13:12 AM10/1/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to scala-l...@googlegroups.com
The "Programming in Scala" book by Odersky, Spoon and Venners has this to say about code inside XML:
An expression inside a brace escape does not have to evaluate to an XML
node. It can evaluate to any Scala value. In such a case, the result is converted
to a string and inserted as a text node.
That is false, as one can easily see:
<li>{42}</li>.child(0).getClass // it's an Atom[Int], not a Text node
Nodes don't get wrapped into atoms:
<li>{<p/>}</li>.child(0).getClass // It's an Elem
I expected that strings get wrapped into Text nodes, but it turns out that's not so.
<li>{"Fred"}</li>.child(0).getClass // It's an Atom[String]
This may be a fine point, but I am wondering where this is specified. Chapter 10 of the language reference doesn't have a lot of detail.
Thanks,
Cay