Skip to content

Instantly share code, notes, and snippets.

@ghais
Created September 13, 2011 19:04
Show Gist options
  • Save ghais/1214734 to your computer and use it in GitHub Desktop.
Save ghais/1214734 to your computer and use it in GitHub Desktop.
class C {
protected var x = 0;
def incr: this.type = { x = x + 1; this }
}
class D extends C {
def decr: this.type = { x = x - 1; this } }
Then we can chain calls to the incr and decr method, as in val d = new D; d.incr.decr;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment