Created
August 15, 2016 16:06
-
-
Save sleexyz/d3821a95576451d8eea2476c0db077ed 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
| class ContextBoundsSyntax { | |
| trait Monoid[A] { | |
| def zero:A | |
| def append (a:A, b:A) : A | |
| } | |
| implicit object AdditiveInt extends Monoid[Int] { | |
| def zero = 0 | |
| def append (a:Int, b:Int) = a + b | |
| } | |
| def gimmeZero[T : Monoid](x: T): T = { | |
| implicitly[Monoid[T]].zero | |
| } | |
| def gimmeZero2[T: Monoid](x: T): T = { | |
| implicitly[Monoid[T]].zero | |
| } | |
| def foo() { | |
| gimmeZero(100) | |
| } | |
| } | |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
gimmeZeroandgimmeZero2are the same disassembled withjavap -c