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

type error in the solution for exercise C.5.13 Soluঞon to: Heroes of the Silver Screen Part 5 #62

Open
ghost opened this issue Mar 2, 2018 · 0 comments

Comments

@ghost
Copy link

ghost commented Mar 2, 2018

Hello,

According to the book the solution could be :

films.foldLeft(0)((a, b) => a.imdbRating + b.imdbRating) / films.length

but a is a sort of accumelator so it do not have the property imdbRating.
The solution that works for me is :

allFilms.foldLeft(0:Double)((a,b) => a + b.imdbRating) / allFilms.length

I have to cast the 0 to Double otherwise the compiler thinks that 0 is a Int and imdbRating is a double and that will not work.

Roelof

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

0 participants