blob: ac9d97d678904bb21be3aa0d708879388e3d508d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
object Test extends App {
val s = "Scala"
val d = 8
val b = false
val f = 3.14159
// 1) number of arguments
new StringContext().f()
new StringContext("", " is ", "%2d years old").f(s)
new StringContext("", " is ", "%2d years old").f(s, d, d)
new StringContext("", "").f()
// 2) Interpolation mismatches
f"$s%b"
f"$s%c"
f"$f%c"
f"$s%x"
f"$b%d"
f"$s%d"
f"$f%o"
f"$s%e"
f"$b%f"
{
implicit val strToInt1 = (s: String) => 1
implicit val strToInt2 = (s: String) => 2
f"$s%d"
}
f"$s%i"
}
|