Skip to content

Instantly share code, notes, and snippets.

@sadache
Created August 17, 2010 13:44
Show Gist options
  • Save sadache/529983 to your computer and use it in GitHub Desktop.
Save sadache/529983 to your computer and use it in GitHub Desktop.
// I really do not like using the syntax that removes points
scala> List("one","two") foldLeft ("") (_+_)
<console>:6: error: missing parameter type for expanded function ((x$1, x$2) => x$1.$plus(x$2))
List("one","two") foldLeft ("") (_+_)
^
// Int ???
scala> List("one","two") foldLeft ("") ((_+_):(String,String) => String)
<console>:6: error: type mismatch;
found : (String, String) => String
required: Int
List("one","two") foldLeft ("") ((_+_):(String,String) => String)
^
scala> List("one","two").foldLeft ("") (_+_)
res2: java.lang.String = onetwo
@sadache
Copy link
Author

sadache commented Aug 18, 2010

I love ML currying, but this is not it and often it gets unpredictable to me. I guess there is a problem of precedence before the type inferencer kicks in. It is very confusing since it is hard to grasp even forgetting about this very case. I don't seem to be getting the mental model and that's why I tent to use it very rarely and only in places where it is clear and obvious.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment