Code: Select all
This reports 15, I believe because foreach() also uses a hidden variable roll.count to track where it is in the string. This is a problem because his code is such that he needs to run the foreach before referencing roll.count. Moreover, if the foreach() sets roll.count high enough, the c() function will terminate after just the initial runthrough.
I believe the solution would be as simple as setting foreach() to use a variable by a different name than roll.count (I recommend for.count), but I'm just guessing.