Skip to content

Instantly share code, notes, and snippets.

@raymcdermott
Created April 7, 2011 21:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raymcdermott/908731 to your computer and use it in GitHub Desktop.
Save raymcdermott/908731 to your computer and use it in GitHub Desktop.
Recursion with locally recursive function with default and named arguments
def scrubOut(line: String, keys: List[String]): String = {
def containsKeys(found: Boolean = false, local_line: String = line, local_keys: List[String] = keys): Boolean = {
if (local_keys.isEmpty || found) found
else {
containsKeys(line.contains(local_keys.head), local_line, local_keys.tail)
}
}
if (!line.contains("=") || !line.contains("\"") || keys.isEmpty || containsKeys() == false)
line
else {
scrubOut(line.replaceAll(keys.head + "=\".*?\"", keys.head + "=\"****\""), keys.tail)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment