Skip to content

Commit aadd3b7

Browse files
committed
Fix syntax in new examples
1 parent 4563c7f commit aadd3b7

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

_tour/singleton-objects.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ import logging.Logger.info
8282
class Project(name: String, daysToComplete: Int)
8383

8484
class Test:
85-
val project1 = new Project("TPS Reports", 1)
86-
val project2 = new Project("Website redesign", 5)
85+
val project1 = Project("TPS Reports", 1)
86+
val project2 = Project("Website redesign", 5)
8787
info("Created projects") // Prints "INFO: Created projects"
8888
```
8989
{% endtab %}
@@ -104,7 +104,7 @@ An object with the same name as a class is called a _companion object_. Converse
104104

105105
{% tab 'Scala 2' for=companion-object-circle %}
106106
```scala
107-
import scala.math._
107+
import scala.math.pow
108108

109109
case class Circle(radius: Double) {
110110
import Circle._
@@ -123,10 +123,10 @@ circle1.area
123123

124124
{% tab 'Scala 3' for=companion-object-circle %}
125125
```scala
126-
import scala.math._
126+
import scala.math.pow
127127

128128
case class Circle(radius: Double):
129-
import Circle._
129+
import Circle.*
130130
def area: Double = calculateArea(radius)
131131

132132
object Circle:
@@ -172,13 +172,13 @@ scalaCenterEmail match {
172172
{% endtab %}
173173

174174
{% tab 'Scala 3' for=companion-object-email %}
175-
```scala mdoc
175+
```scala
176176
class Email(val username: String, val domainName: String)
177177

178178
object Email:
179179
def fromString(emailString: String): Option[Email] =
180180
emailString.split('@') match
181-
case Array(a, b) => Some(new Email(a, b))
181+
case Array(a, b) => Some(Email(a, b))
182182
case _ => None
183183

184184
val scalaCenterEmail = Email.fromString("scala.center@epfl.ch")

0 commit comments

Comments
 (0)