Skip to content

Commit ce4df84

Browse files
committed
forEachに変えました。
1 parent 3763ca5 commit ce4df84

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

src/main/kotlin/xyz/javecs/tools/text2expr/Text2Expr.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@ class Text2Expr(rulePath: String = "rules") {
1111
private val calc = Calculator()
1212

1313
init {
14-
resources(rulePath).forEach{ rules.add(RuleBuilder(read(it))) }
14+
resources(rulePath).forEach { rules.add(RuleBuilder(read(it))) }
1515
}
1616

1717
fun eval(text: String): String {
18-
for (rule in rules) {
18+
rules.forEach {
1919
try {
20-
val evaluation = rule.eval(text)
21-
if (evaluation.value != Double.NaN) {
22-
return evaluation.value.toString()
23-
}
20+
val evaluation = it.eval(text)
21+
if (evaluation.value != Double.NaN) return evaluation.value.toString()
2422
} catch (e: Exception) {
2523
}
2624
}

0 commit comments

Comments
 (0)