Last active
December 19, 2015 13:29
-
-
Save drostron/5962943 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| object Common { | |
| trait I[A, B] { | |
| def apply(a: A): B | |
| } | |
| def i[A, B](f: A => B): I[A, B] = new I[A,B] { | |
| def apply(a: A) = f(a) | |
| } | |
| case class Z(boz: String) | |
| } | |
| import Common._ | |
| object WorkingCase { | |
| val bozy: I[String, Z] = i(newBoz => Z(boz = newBoz)) | |
| val boz = bozy("zob") | |
| } | |
| object BuggyCase { | |
| val bozy = i[String, Z](newBoz => Z(boz = newBoz)) | |
| val boz = bozy("zob") // fails?! | |
| } |
Author
Correct. Seems to be something to do with a named parameter clashing with the assignment variable name in this particular case. Strange.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This works fine for me under Scala 2.10.2 if you leave off the named argument ("boz") when calling Z.apply in each case. If you leave it in, it generates an interesting error: