Use FoldRight() instead of for loop
This commit is contained in:
parent
8db2e8829f
commit
55c992bb3a
@ -178,12 +178,9 @@ object TestGenerator extends App {
|
|||||||
val topModuleName = args(1)
|
val topModuleName = args(1)
|
||||||
val configClassName = args(2)
|
val configClassName = args(2)
|
||||||
|
|
||||||
val aggregateConfigs = configClassName.split('_').reverse
|
val aggregateConfigs = configClassName.split('_')
|
||||||
|
|
||||||
var finalConfig = new Config()
|
val finalConfig = aggregateConfigs.foldRight(new Config()) { case (currentConfigName, finalConfig) =>
|
||||||
var ii = 0;
|
|
||||||
for (ii <- 0 to (aggregateConfigs.length - 1)) {
|
|
||||||
val currentConfigName = aggregateConfigs(ii);
|
|
||||||
val currentConfig = try {
|
val currentConfig = try {
|
||||||
Class.forName(s"$projectName.$currentConfigName").newInstance.asInstanceOf[Config]
|
Class.forName(s"$projectName.$currentConfigName").newInstance.asInstanceOf[Config]
|
||||||
} catch {
|
} catch {
|
||||||
@ -192,7 +189,7 @@ object TestGenerator extends App {
|
|||||||
"\" of configClassName \"" + configClassName +
|
"\" of configClassName \"" + configClassName +
|
||||||
"\", did you misspell it?", e)
|
"\", did you misspell it?", e)
|
||||||
}
|
}
|
||||||
finalConfig = currentConfig ++ finalConfig
|
currentConfig ++ finalConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
val world = (new Config(finalConfig)).toInstance
|
val world = (new Config(finalConfig)).toInstance
|
||||||
|
Loading…
Reference in New Issue
Block a user