Copypaste issue in example 6.2 Apply Syntax
voropaevp opened this issue · 2 comments
voropaevp commented
In chapter 6.2 Apply Syntax
Book version:
(Option(1), Option(2), Option(3)).mapN(add)
// error: ':' expected but '(' found.
// Option("Garfield"),
// ^
// error: identifier expected but '}' found.
(Option("cats"), Option(true)).mapN(add)
// error: ':' expected but '(' found.
// Option("Garfield"),
// ^
// error: identifier expected but '}' found.
Correct version:
scala> (Option(1), Option(2), Option(3)).mapN(add)
^
error: type mismatch;
found : (Int, Int) => Int
required: (Int, Int, Int) => ?
(Int, Int) => Int <: (Int, Int, Int) => ??
false
scala> (Option("cats"), Option(true)).mapN(add)
^
error: type mismatch;
found : (Int, Int) => Int
required: (String, Boolean) => ?
(Int, Int) => Int <: (String, Boolean) => ??
false
jacospain commented
This remains an issue. You can get the compiler output from the book if you run the example code from the chapter with no newline between this case class definition and the immediately following expression:
final case class Cat(name: String, born: Int, color: String)
(
Option("Garfield"),
Option(1978),
Option("Orange & black")
)
Darkest commented
This remains an issue. You can get the compiler output from the book if you run the example code from the chapter with no newline between this case class definition and the immediately following expression:
final case class Cat(name: String, born: Int, color: String) ( Option("Garfield"), Option(1978), Option("Orange & black") )
Nevertheless i think the compiler output in the book should be fixed