Skip to content

Instantly share code, notes, and snippets.

@t3hnar
Created February 7, 2012 10:47
Show Gist options
  • Save t3hnar/1759072 to your computer and use it in GitHub Desktop.
Save t3hnar/1759072 to your computer and use it in GitHub Desktop.
Scala types with java classes
public class JavaClass {
public String toString() {
return ""
}
public boolean getBool() {
return false
}
}
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