Created
April 28, 2011 20:26
-
-
Save p3t0r/947259 to your computer and use it in GitHub Desktop.
This file contains 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
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