FunctionalProgrammingSimplified icon indicating copy to clipboard operation
FunctionalProgrammingSimplified copied to clipboard

page 480: claim of "case classes don’t allow the use of the new keyword" isn't true

Open jim-miller opened this issue 5 years ago • 0 comments

Although not idiomatic, case classes can indeed be constructed using new. Subsequently looking for the new keyword is not actually a giveaway that the anonymous class used in the example isn't a case class as claimed on page 480.

e.g., this works just fine:

object Main extends App {
  val p = new Person("Jim", 45)

  println(p)
}

case class Person(name: String, age: Int)

jim-miller avatar Oct 17 '19 16:10 jim-miller