How to write two-dimensional array to xml in Scala 2.8.0
Posted
by Shadowlands
on Stack Overflow
See other posts from Stack Overflow
or by Shadowlands
Published on 2010-04-22T05:33:26Z
Indexed on
2010/04/22
5:43 UTC
Read the original article
Hit count: 280
The following code (copied from a question from about a year ago) works fine under Scala 2.7.7, but does not behave correctly under Scala 2.8.0 (Beta 1, RC8).
import scala.xml
class Person(name : String, age : Int) {
def toXml(): xml.Elem =
<person><name>{ name }</name><age>{ age }</age></person>
}
def peopleToXml(people: Array[Person]): xml.Elem = {
<people>{ for {person <- people} yield person.toXml }</people>
}
val data = Array(new Person("joe",40), new Person("mary", 35))
println(peopleToXml(data))
The output (according to 2.7.7) should be:
<people><person><name>joe</name><age>40</age></person><person><name>mary</name><age>35</age></person></people>
but instead comes out as:
<people>\[Lscala.xml.Elem;@17821782</people>
How do I get this to behave as it did in 2.7.x?
© Stack Overflow or respective owner