Sorry, kind of new to the language. Earlier in this book I’m reading,
“Learn to Program” by Chris P., he talked about how methods do not
affect variables. But in this program, it seems like the indicies of
world are affected globally.
From what I understand from looking at the code, when the method,
continent_size, finds ‘land’, it will change it to ‘counted land.’ This
“new world” with the changed ‘counted land’ then gets passed into
another continent_size, so that’s why the recursive calls will skip over
the ‘counted land.’
BUT, I would think that if 2 separate recursive calls, let’s say to
(4,5) and (6,5), which are both land, when they check (5,6), they would
BOTH count it as ‘land.’
The only way I can see this not happening is if the array, world, is
globally affected… or if there’s something about the code returning
world to itself after the recursive calls which I am not seeing.
Please help explain! Thanks!