Created
July 4, 2012 00:01
-
-
Save agmcleod/3044254 to your computer and use it in GitHub Desktop.
Getting nil for a variable in one case but not another.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# player is in attr_accessor call inside the class. | |
# no error thrown | |
def render(gc, sbg, g) | |
@player.graphic | |
draw_surfaces | |
g.translate offset_x, offset_y | |
end | |
# (NoMethodError) undefined method `+' for nil:NilClass | |
def render(gc, sbg, g) | |
@player.graphic.draw((@player.x + offset_x), @player.y) | |
draw_surfaces | |
g.translate offset_x, offset_y | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment