Stein Dekker
Stein Dekker

Reputation: 803

How to call super class method within class

How can I call super class method within class like:

class A  
  def foo  
    puts "lol"  
  end  
end

class B < A  
  foo  
end

Upvotes: 1

Views: 112

Answers (1)

tadman
tadman

Reputation: 211580

You're trying to call an instance method from within the context of a class. This is not valid.

What would work:

class A  
  def self.foo  
    puts "lol"  
  end  
end

class B < A  
  foo
end

Upvotes: 4

Related Questions