8000 scala3-book: Fix abstract class example · aresen/docs.scala-lang@b5ecddb · GitHub
[go: up one dir, main page]

Skip to content

Commit b5ecddb

Browse files
committed
scala3-book: Fix abstract class example
Use `name` parameter inside the abstract class
1 parent 198cd0d commit b5ecddb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

_overviews/scala3-book/domain-modeling-tools.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ Prior to Scala 3, when a base class needed to take constructor arguments, you’
413413
abstract class Pet(name: String):
414414
def greeting: String
415415
def age: Int
416-
override def toString = s"I say $greeting, and I’m $age"
416+
override def toString = s"My name is $name, I say $greeting, and I’m $age"
417417

418418
class Dog(name: String, age: Int) extends Pet(name):
419419
val greeting = "Woof"

0 commit comments

Comments
 (0)
0