FunctionalProgrammingSimplified
FunctionalProgrammingSimplified copied to clipboard
page 480: claim of "case classes don’t allow the use of the new keyword" isn't true
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)