Skip to content

Commit d649d6c

Browse files
alvinjjulienrf
andauthored
Update _overviews/overview/a-taste-of-scala.md
Co-authored-by: Julien Richard-Foy <[email protected]>
1 parent 56ecf52 commit d649d6c

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

_overviews/overview/a-taste-of-scala.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -245,18 +245,13 @@ println(s"Name: $firstName $mi $lastName") // "Name: John C Doe"
245245

246246
Just precede the string with the letter `s`, and then put a `$` symbol before your variable names inside the string.
247247

248-
To enclose class fields, class methods, or equations inside a string, enclose them in curly braces:
248+
To enclose expressions inside a string, enclose them in curly braces:
249249

250-
```scala
251-
class Person(var name: String)
252-
val p = Person("Margaret Hamilton")
253-
254-
// a class field or method
255-
println(s"Name: ${p.name}") // "Name: Margaret Hamilton"
256-
257-
// an equation
250+
~~~ scala
258251
println(s"2 + 2 = ${2 + 2}") // prints "2 + 2 = 4"
259-
```
252+
val x = -1
253+
println(s"x.abs = ${x.abs}") // prints "x.abs = 1"
254+
~~~
260255

261256
#### Other interpolators
262257

@@ -1326,4 +1321,3 @@ Scala has even more features that weren’t covered in this whirlwind tour. See
13261321

13271322

13281323

1329-

0 commit comments

Comments
 (0)