Play Roadmap has been published. The major feature will be the support of scala 2.10 version.
By using Play 2.1 we can start profiting with String interpolation
STRING INTERPOLATION: QUICK EXAMPLE ?
val n = 20
"Bob is "+n+" years old"
can be replaced by :
s"Bob is $n years old"
The benefit of using String interpolation are :
PLAY 2.1
On Play framework an sample action can be :
def index = Action {
val version = 2.10
Ok("hello scala "+ version)
}
And by String interpolation we can rewrite it as :
def index = Action {
val version = 2.10
Ok(s"hello scala $version")
}
BETTER !
Let’s do better and remove parenthesizes and ‘s’ characters
First create an implicit class (scala 2.10 features) to wrap a call to Ok object and define an ok object :
implicit class HTTPInterpolation(s: StringContext) {
object ok {
def apply(exprs: Any*) = {
Ok(s.s(exprs: _*))
}
}
}
Now we can use it as
def index = Action {
val version = 2.10
ok"hello scala $version"
}
Short and concise !