You are viewing a single comment's thread. Return to all comments →
arr.foldLeft(List[Int]())((acc,v) => v::acc)
Is there anyway I can get a detailed explanation of how this works? This is fascinating.
Scala api and :: is concatenation
List[Int] is accumulator, () near List[Int] means that it's an empty List at the beginning; (acc, v) => v:acc is a function that receives accumulator and value from left and than adds this into List - :: operation.
try in console: 5::4::3::2::1::Nil