From: Enrique Comba Riepenhausen Date: 2007-05-26T05:49:48+09:00 Subject: Re: printing nil objects On 25 May 2007, at 22:40, finer recliner wrote: > On May 25, 4:31 pm, Enrique Comba Riepenhausen wrote: >>> ### code starts here ### >>> c1 = Node.new(1,nil,nil) >>> c2 = Node.new(2,nil,nil) >>> c3 = Node.new(3,nil,nil) >> >>> c1.setP1(c2) >>> c1.setP2(c2) >>> c2.setP1(c3) >> >>> current = c1 >>> while current.getP1 != nil >>> print "value = #{current.getV}, pointer1 = # >>> {current.getP1.getV}, >>> " >>> if current.getP2.getV != nil then print "pointer2 = >>> #{current.getP2.getV}\n" else print "null\n" end >>> current = current.getP1 >>> end >>> [/code] >> >> Your problem lies exactly there. You are trying to make a method call >> (getV) on a nil object, and obviously it doesn't have the (getV) >> method... >> >> Try the following >> >> if current.getP2.nil? then.... >> >> That should work. >> >> Cheers, >> >> ---- >> Enrique Comba Riepenhausen >> eco...@mac.com >> >> I always thought Smalltalk would beat Java, I just didn't know it >> would be called 'Ruby' when it did. >> -- Kent Beck > > ooooh. now i feel foolish lol. thanks! Why should you? No one is perfect and sometimes when in the middle of the brain crunching activity we oversee the simplest things... :) Cheers, ---- Enrique Comba Riepenhausen ecomba@mac.com I always thought Smalltalk would beat Java, I just didn't know it would be called 'Ruby' when it did. -- Kent Beck