From: Mike Agres Date: 2006-10-09T11:46:35+09:00 Subject: Re: Learn to Program, by Chris Pine I'm having some issues modifying the Civ continent example from ch. 10 to account for coordinates that are outside the array. I added the following line: if ((y <= 10 && y > 0) && (x <= 10 && x > 0)) before... # So, first we count this tile... size = 1 world[y][x] = 'counted land' # ...then we count all of the # neighboring eigth tiles (and, # of course, their neighbors via recursion) size = size + continent_size(world, x-1, y-1) #4,4 size = size + continent_size(world, x , y-1) #5,4 size = size + continent_size(world, x+1, y-1) #6,4 size = size + continent_size(world, x-1, y ) #4,5 size = size + continent_size(world, x+1, y ) #6,5 size = size + continent_size(world, x-1, y+1) #4,6 size = size + continent_size(world, x , y+1) #5,6 size = size + continent_size(world, x+1, y+1) #6,6 size end As a result, I get the following error: TypeError: nil can't be coerced into Fixnum method + in civilization.rb at line 35 method continent_size in civilization.rb at line 35 method continent_size in civilization.rb at line 35 method continent_size in civilization.rb at line 36 method continent_size in civilization.rb at line 35 method continent_size in civilization.rb at line 40 method continent_size in civilization.rb at line 39 method continent_size in civilization.rb at line 41 method continent_size in civilization.rb at line 39 method continent_size in civilization.rb at line 41 method continent_size in civilization.rb at line 39 method continent_size in civilization.rb at line 36 method continent_size in civilization.rb at line 35 at top level in civilization.rb at line 48 This error appears regardless of whether the arguments I pass are in 5,5 (as in the example Chris Pine wrote out) or something like 10,10 (which is on the edge of the 'continent'). Is that the right conditional statement? Could it be in the wrong place in the method? -- Posted via http://www.ruby-forum.com/.