Skip to content

Instantly share code, notes, and snippets.

@teamon
Created October 2, 2010 17:38
Show Gist options
  • Save teamon/607819 to your computer and use it in GitHub Desktop.
Save teamon/607819 to your computer and use it in GitHub Desktop.
implicit def repl4str(s: String) = new Object {
def %(pairs: (String, String)*) = (s /: pairs){ case (s, (k, v)) => s.replace("%{" + k + "}", v) }
}
"foo %{bar} and %{baz}" % ("bar" -> "xxx", "baz" -> "blah") // "foo xxx and blah"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment