Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
yblu
on March 31, 2017
|
parent
|
context
|
favorite
| on:
Thirteen Years of Bad Game Code
This `for` loop looks particularly curious to me:
for (int i = this.bindings.Count - 1; i >= 0; i = Math.Min(this.bindings.Count - 1, i - 1))
Why isn't the last expression a normal i--?
et1337
on March 31, 2017
[–]
Because bindings[10] might have triggered a process that removes bindings 7-9, causing "i" to be out of bounds of the array. I wanted to continue updating the remaining bindings even if some of them got removed.
yblu
on April 1, 2017
|
parent
[–]
Wow, that's pretty subtle. Thanks for explaining.
Join us for
AI Startup School
this June 16-17 in San Francisco!
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: