Can anyone tell me what’s wrong with my code? Play...
# fp-in-kotlin
r
Can anyone tell me what’s wrong with my code? Playground link: https://pl.kotl.in/aRLlyLmso
t
This should fix it 🙂
Copy code
println(lineBuild.filter { it.procedure.map{ it.activity }.contains(LineBuildActivity.HOLD) })
it.procedure produces a List<Procedure>, and you are checking if it contains a LineBuildActivity which is a property of Procedure
Something like this might be slightly more optimized:
Copy code
println(lineBuild.filter { it.procedure.firstOrNull{ it.activity == LineBuildActivity.HOLD} != null })
since it saves you a map operation
1
Just joined this channel, just saw this was 3 days old 🤦
🙏 1