Last active
January 3, 2016 11:29
-
-
Save kareblak/8456943 to your computer and use it in GitHub Desktop.
Where's the structural type?
This file contains 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 FuncConversions { | |
//Nay | |
implicit def guavaFunction2function[A, R](fn: (A) => R) = { | |
new com.google.common.base.Function[A, R]{ | |
def apply(input: A): R = fn(input) | |
} | |
} | |
//Yay | |
class Func[A, B](fn: (A) => B) extends com.google.common.base.Function[A, B] { | |
def apply(input: A): B = fn(input) | |
} | |
implicit def guavaFunction2function[A, B](fn: (A) => B) = new Func[A, B](fn) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment