// scala code
object Example1 {
val x = <a> This is some xml.<b/></a>
val x1 = <a>{"hello" + " world"}</a>
val x2 = (<a>{
"hello world".split("""\s+""").mkString("*")
}}</a>)
val yearMade = 1996
val x3 = <a> { if(yearMade < 2000) <old>{yearMade}</old> else <new>{yearMade}</new> } </a>
abstract class CCTherm {
val description: String
val yearMade: Int
val dateObtained: String
val bookPrice: Int
val purchasePrice: Int
val condition: Int
override def toString = description
def toXML = <cctherm> <description>{description}</description> <yearMade>{yearMade}</yearMade> <dateObtained>{dateObtained}</dateObtained> <bookPrice>{bookPrice}</bookPrice> <purchasePrice>{purchasePrice}</purchasePrice> <condition>{condition}</condition> </cctherm>
}
val therm = new CCTherm {
override val condition: Int = 10
override val description: String = "Nice book"
override val bookPrice: Int = 13
override val purchasePrice: Int = 2341
override val yearMade: Int = 1953
override val dateObtained: String = "March 14, 2006"
}
therm.toXML
val x4 = <a>{{{{Brace yourself}}}}</a>
val x5 = <a>input ----> output</a>
x5.text
}
Tuesday, October 20, 2015
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment