scruffyfox
07/24/2017, 2:31 PMfun searchParent(id: String): Module?
{
modules.forEach { module ->
val ret = searchParent(module, id)
if (ret != null)
{
return@searchParent ret
}
}
return null
}
kingsley
07/24/2017, 2:33 PMreturn@searchParent
does a local return (within the lambda) rather than a function return. You need to return ret
insteadscruffyfox
07/24/2017, 2:34 PMkingsley
07/24/2017, 2:34 PMreturn@searchParent
isn’t even valid codescruffyfox
07/24/2017, 2:34 PMkingsley
07/24/2017, 2:34 PMreturn xyz
scruffyfox
07/24/2017, 2:35 PMscruffyfox
07/24/2017, 2:35 PMscruffyfox
07/24/2017, 2:36 PMscruffyfox
07/24/2017, 2:36 PMfun searchParent(root: Module, id: String): Module?
{
root.steps?.forEach { step ->
val ret = searchParent(step, id)
if (ret == null)
{
if (step.id == id)
{
return root
}
}
}
return null
}
minus
07/24/2017, 2:36 PMscruffyfox
07/24/2017, 2:36 PMscruffyfox
07/24/2017, 2:46 PM