Skip to content

Instantly share code, notes, and snippets.

@csexton
Forked from anonymous/gist:515749
Created August 9, 2010 17:33
Show Gist options
  • Save csexton/515754 to your computer and use it in GitHub Desktop.
Save csexton/515754 to your computer and use it in GitHub Desktop.
class Person
attr_accessor :name, :weight
#want to set a default for @weight in here
#Tried @weight ||= 45 and
# @weight = 45 and
# self.weight = 45
def initialize
@weight = 45
end
end
class Programmer < Person
attr_accessor :programming_ability
end
Programmer.new.weight
# => 45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment