© 2026 LinearBytes Inc.
Search posts, tags, users, and pages
Ahmed Mahmoud
Front-end development
I don't see nesting here. I see Class (Model), Method, and iteration 🤷♂️.
The nesting would be to have multiple iterations inside each other, or multiple callbacks, that would be arguably harder to read. But this example is perfectly fine.
Đăng Tú
I'm ME! Surprise!
So a callback inside a loop isn't called a nest?How about this one?
int Number::maxConsecutiveNumber1() { vector<int> data = convert(BIN); int maxCNo1 = 0; // Consecutive Number of 1 int CNo1 = 0; for (unsigned i = 0; i < data.size(); i++) { if (data[i] == 1) { CNo1 += 1; if (data[i+1] == 0) { maxCNo1 = (CNo1 > maxCNo1) ? CNo1: maxCNo1; } else continue; } } return maxCNo1; }
Matt Strom
Software Engineer, TypeScript ninja
Do you mean a "recursive function"?
Callback from other functions couldn't count as recursive right?
Jason Knight
The less code you use, the less there is to break
Beat me to it, my answer as well was going to be "what nesting" -- much less "and what is the alternative?!?"