Skip to content

Instantly share code, notes, and snippets.

@Krasnyanskiy
Last active July 9, 2016 08:23
Show Gist options
  • Save Krasnyanskiy/86f800ff5c9a807e6d5442dec83f7e6b to your computer and use it in GitHub Desktop.
Save Krasnyanskiy/86f800ff5c9a807e6d5442dec83f7e6b to your computer and use it in GitHub Desktop.
-scala: interview questions
sealed trait Plus[P] {
def ~+[T <: Plus[T]](x: T, y: T): T
}
sealed trait Int extends Plus[Int]
class PlusInt[PI] extends Plus[PI] {
def ~+[T <: Plus[T]](x: T, y: T) = x.~+(y, x)
}
case class TinyPlusInt() extends PlusInt[Int]
case class HugePlusInt() extends PlusInt[Int]
TinyPlusInt().~+(HugePlusInt(), HugePlusInt())
@Krasnyanskiy
Copy link
Author

What's wrong with that code?

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