Created
February 7, 2012 10:47
-
-
Save t3hnar/1759072 to your computer and use it in GitHub Desktop.
Scala types with java classes
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
public class JavaClass { | |
public String toString() { | |
return "" | |
} | |
public boolean getBool() { | |
return false | |
} | |
} |
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
type WrongType = { | |
def toString: String | |
def getBool: Boolean | |
} | |
type RightType = { | |
def toString: String | |
def getBool(): Boolean | |
} | |
def testRight(x: RightType) { | |
// | |
} | |
def testWrong(x: WrongType) { | |
// | |
} | |
testRight(new JavaClass()) // COMPILES | |
testWrong(new JavaClass()) // DOESN'T COMPILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment