Page 1 of 1
undefined method `*' for nil:NilClass
Posted: Tue Jan 22, 2013 3:15 am
by tor
So what am I doin wrong here?
Code: Select all
rectbounds3=[@width*0.5-@ledw*0.5,@hight*0.5-@ledh*0.5,@ledw,@ledh]
fade3=LinearGradientBrush.new rectbounds3,@c3,@c4,45,true
v.drawRoundRect fade3,rectbounds3,@round
NoMethodError: undefined method `*' for nil:NilClass
Re: undefined method `*' for nil:NilClass
Posted: Tue Jan 22, 2013 5:02 am
by tor
I found if I move the mulitpliers in front of the @ floats like this: 0.5*@hight-0.5*@ledh
I get this error instead: TypeError: (in method 'draw'): nil cant be coerced into Float
And after some googling I learned that in this case it is most likely that @ledh and @ledw is nil. Question is why?
When I edit the values in the green floats outside the code that feed theese two values the error disappears while i write a new value. But the moment i press enter to set the value, the error is back.
Re: undefined method `*' for nil:NilClass
Posted: Tue Jan 22, 2013 10:02 am
by trogluddite
tor wrote:@hight
should be
I do this 50 times a day! If you don't spell a variable right, it counts as undeclared and returns 'nil'.
Re: undefined method `*' for nil:NilClass
Posted: Tue Jan 22, 2013 7:06 pm
by tor
dang... I just could not see it. Checked it over and over and over
THANK YOU TROG

This is probably going to be one of my biggest challenges with a language like Ruby, getting the spelling right.