How would you get my 'def showVars' built within the 'second' class to output the 'puts (variables)' that it inherited from the 'First' class?
class First
@@varOne = 1
CONSTANT_ONE = 10
end
class Second < First
def showVars
puts @@varOne
puts CONSTANT_ONE
end
end
My failed attempt:
class First
@@varOne = 1
CONSTANT_ONE = 10
end
class Second < First
def showVars
puts @@varOne
puts CONSTANT_ONE
end
end
puts Second.showVars # <-- fails
puts Second.new.showVarsWorks. You have defined an instance method, not a class method.show_vars. Capital letters are reserved forClassNameandCONSTANT_NAMEsituations and have specific meaning in the syntax.