type error in the solution for exercise C.5.13 Soluঞon to: Heroes of the Silver Screen Part 5
Opened this issue · 0 comments
Deleted user commented
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