Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2019
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.41 KB | None | 0 0
  1. object Main extends App
  2. {
  3.   def f(acc : Map[Char, String], s: String) = acc.+((s.head, s))
  4.   val myList = List("abc", "bcd", "cde", "def", "efg")
  5.   val w = myList.fold(Map[Char, String]())(f)
  6.   print(w)
  7. }
  8.  
  9. /*
  10. Error:(5, 44) type mismatch;
  11.  found   : (Map[Char,String], String) => scala.collection.immutable.Map[Char,String]
  12.  required: (Object, Object) => Object
  13.   val w = myList.fold(Map[Char, String]())(f)
  14. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement