Skip to content

Instantly share code, notes, and snippets.

@piotrga
Created December 29, 2011 10:43
Show Gist options
  • Save piotrga/1533450 to your computer and use it in GitHub Desktop.
Save piotrga/1533450 to your computer and use it in GitHub Desktop.
Pimping the String
implicit def toRichString(s:String) : RichString = new RichString(s)
class RichString(s: String){
def saveAs(fileName: String) = write(fileName, s)
private[this] def write(fileName: String, content: String) {
val f = new FileWriter(fileName)
f.write(content)
f.close()
}
}
"My string I want to save".saveAs("some/file/name.txt")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment