We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3763ca5 commit ce4df84Copy full SHA for ce4df84
1 file changed
src/main/kotlin/xyz/javecs/tools/text2expr/Text2Expr.kt
@@ -11,16 +11,14 @@ class Text2Expr(rulePath: String = "rules") {
11
private val calc = Calculator()
12
13
init {
14
- resources(rulePath).forEach{ rules.add(RuleBuilder(read(it))) }
+ resources(rulePath).forEach { rules.add(RuleBuilder(read(it))) }
15
}
16
17
fun eval(text: String): String {
18
- for (rule in rules) {
+ rules.forEach {
19
try {
20
- val evaluation = rule.eval(text)
21
- if (evaluation.value != Double.NaN) {
22
- return evaluation.value.toString()
23
- }
+ val evaluation = it.eval(text)
+ if (evaluation.value != Double.NaN) return evaluation.value.toString()
24
} catch (e: Exception) {
25
26
0 commit comments