Xml Literals
Viewing old version f13da3aac136bd3e3fa27a8e8a4c88a99bbc0847; View Current
Scala supports XML literals. Meaning that this program:
outputs this:
This syntax can do more than just save you a few quotes and backslashes, however. You can use curly braces to dynamically insert expressions, as such:
Note how we don’t quote the title or href attributes; Scala knows that we are assigning XML attributes to dynamic variables (i.e. this isn’t just blind templating; it’s XML-aware). Also note how the quoted string we pass to the function gets escaped inside the attribute value.
Last Updated 07/25/2009 at 02:14:36 PM by davec
blog comments powered by Disqus
All Content by David Copeland is licensed under a
Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.