Skip to content

Instantly share code, notes, and snippets.

@p3t0r
Created April 28, 2011 20:26
Show Gist options
  • Save p3t0r/947259 to your computer and use it in GitHub Desktop.
Save p3t0r/947259 to your computer and use it in GitHub Desktop.
package com.log4.methodmissing
import java.io.File
class Path(name: String = "", parent: Option[Path] = None) extends Dynamic {
def applyDynamic(methodName: String)(args: Any*) = new Path(methodName, Option(this))
override def toString = (if(parent.isDefined) parent.get.toString + File.separatorChar else "") + name
}
object BuilderExample {
def main(args: Array[String]) {
println( // prints something like: /home/Users/peter/Documents
new Path().home.Users.peter.Documents
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment