+ 2
unexpected error(Solved)
Ok, I can't understand why this admittedly unnecessarily complicated one liner cannot be used in a for loop. It works when arguments are passed directly but raises error in the for loop. Is this a limitation of the walrus operator or the lambda scope getting messed up? Any ideas? I like to experiment a bit and push the code to see what it takes to break it. It breaks here... (Solved, thanks to insight provided by Jay Matthews ' feedback.) https://code.sololearn.com/cve349Ch6v5k/?ref=app https://code.sololearn.com/cPp7I7Eh68eO/?ref=app
3 Respuestas
0
Jay Matthews
you're right!
so it's not about the for range, but about arguments fed to it.
it fails on mtx(0) and mtx(1).
what's going on?
0
Jay Matthews
agreed. Maybe the lambda was wrongly written?
The commented out functions below that all works down to 0.
Nesting lambdas is tricky.
0
Jay Matthews
Thanks to your insight, I decided to take out the inner nested lambda and put it in the outer lambda parameter, so the nesting weirdness go away.