KEMBAR78
String Interpolation in Scala | BoldRadius | PDF
String	
  interpola-on	
  
WHY?	
  
error: unclosed string literal
WHY?	
  
"Hello " + user + ", the
time is " + now + better
hurry up!"
An	
  example	
  
import System.{currentTimeMillis => now}

val user = "Kevin”

val m = "Hello " + user + ", the time is " + now +
better hurry up!"

// Hello Kevin, the time is 1429017560259
better hurry up!
Enter	
  string	
  interpola-on	
  
import System.{currentTimeMillis => now}

val user = "Kevin”

val m = s"Hello $user, the time is $now better
hurry up!"

// Hello Kevin, the time is 1429017560259
better hurry up
Built-­‐in	
  interpolators	
  
s"Simple string interpolation, $user"

f"Formatted interpolation: $balance%5.2f"

raw"Raw respects t escaped n literals"
Slick	
  implements	
  interpolators	
  
sql"select * from books where id = $id"

sqlu"""
delete from products 
where expiration > $date
"""
Build	
  your	
  own!	
  
StringContext	
  

hBp://docs.scala-­‐lang.org
String Interpolation in Scala | BoldRadius

String Interpolation in Scala | BoldRadius