Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copypaste issue in example 6.2 Apply Syntax #196

Open
voropaevp opened this issue Sep 12, 2020 · 2 comments
Open

Copypaste issue in example 6.2 Apply Syntax #196

voropaevp opened this issue Sep 12, 2020 · 2 comments

Comments

@voropaevp
Copy link

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
Copy link

jacospain commented Aug 4, 2021

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
Copy link

Darkest commented Aug 12, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants