Skip to content

Instantly share code, notes, and snippets.

@faisal00813
Last active November 7, 2016 10:33
Show Gist options
  • Save faisal00813/260d2f2ee5826f151153e0ccc4cbc46b to your computer and use it in GitHub Desktop.
Save faisal00813/260d2f2ee5826f151153e0ccc4cbc46b to your computer and use it in GitHub Desktop.
Substitues the variable with the value provided
/**code taken from http://stackoverflow.com/a/4051500/845019
* substitutes the string with #{variableName} format
*/
implicit def RichFormatter(string: String) = new {
def richFormat(replacement: Map[String, Any]) =
(string /: replacement) { (res, entry) => res.replaceAll("#\\{%s\\}".format(entry._1), entry._2.toString) }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment