Last active
August 29, 2015 14:05
-
-
Save aoiroaoino/f93a75c63a68a5a4a374 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
val table = Map( "%one%" -> "1", "%two%" -> "2", "%three%" -> "3" ) | |
// ↓もっとカッコ良く書けないかな?? | |
def replaceSpecialWords(target: String) = { | |
var str = target | |
table.keys.foreach { key => | |
str = str.replaceAll(key, table(key)) | |
} | |
str | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ループ内で呼ばれる想定のメソッドだからtable.keysを何回もまわしたくない