Skip to content

Instantly share code, notes, and snippets.

@Epictetus
Forked from shugo/wrong protected
Created October 16, 2012 03:53
Show Gist options
  • Save Epictetus/3897156 to your computer and use it in GitHub Desktop.
Save Epictetus/3897156 to your computer and use it in GitHub Desktop.
Wrong example of proteted
class Node {
def eval(other: Node): Unit = other.protected_method(this)
protected def protected_method(other: Node) = other
}
class NodeFake(node: Node) extends Node {
override def eval(other: Node): Unit = {
println("pre")
println(this == other.protected_method(this))
println("pre")
}
}
new NodeFake(new Node()).eval(new Node())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment