Discord is now Scala’s main chat platform. Please join us at https://discord.com/invite/scala
def earliestFilm = mcTiernan.films.foldLeft(Int.MaxValue) { (current, film) => math.min(current, film.yearOfRelease)
val films = directors.flatMap(director => director.films)
def averageScore:Int = films.foldLeft(0)((a, b) => a.imdbRating + b.imdbRating) / films.length
Error:(60, 58) value imdbRating is not a member of Int
def averageScore:Int = films.foldLeft(0)((a, b) => a.imdbRating + b.imdbRating) / films.length
a
isn't the type you think it is
sum
is equivalent to reduce(_ + _)
, or fold(0)(_ + _)