Skip to content

Instantly share code, notes, and snippets.

@drostron
Last active December 19, 2015 13:29
Show Gist options
  • Select an option

  • Save drostron/5962943 to your computer and use it in GitHub Desktop.

Select an option

Save drostron/5962943 to your computer and use it in GitHub Desktop.
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?!
}
@drostron
Copy link
Copy Markdown
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