My class include a Module and overwrite a method of the Module. In this
method, I want to invoke the Module's method first. Just like
"super.method()" in Java. How can I do this?
···
--
Posted via http://www.ruby-forum.com/.
My class include a Module and overwrite a method of the Module. In this
method, I want to invoke the Module's method first. Just like
"super.method()" in Java. How can I do this?
--
Posted via http://www.ruby-forum.com/.
Zhao Yi wrote:
My class include a Module and overwrite a method of the Module. In this
method, I want to invoke the Module's method first. Just like
"super.method()" in Java. How can I do this?
Just the word super().
module M
def q(arg)
#
end
end
class K
include M
def q(arg)
#
super(arg)
end
end
super() calls ancestor's function with the same name as the function
you're currently in.
TPR.
--
Posted via http://www.ruby-forum.com/\.
Hi --
Zhao Yi wrote:
My class include a Module and overwrite a method of the Module. In this
method, I want to invoke the Module's method first. Just like
"super.method()" in Java. How can I do this?Just the word super().
module M
def q(arg)
#
end
end
class K
include M
def q(arg)
#
super(arg)
end
endsuper() calls ancestor's function with the same name as the function
you're currently in.
Keep in mind, though, that the semantics of super (which is a keyword,
rather than a method) are a bit different from regular method-calling
semantics:
super # call ancestor's method with current arguments
super(a,b) # call with exactly the arguments (a,b)
super() # call with no arguments
It's really the first one that's the special case, as you can see.
David
On Sun, 31 Aug 2008, Thomas B. wrote:
--
Rails training from David A. Black and Ruby Power and Light:
Intro to Ruby on Rails January 12-15 Fort Lauderdale, FL
Advancing with Rails January 19-22 Fort Lauderdale, FL *
* Co-taught with Patrick Ewing!
See http://www.rubypal.com for details and updates!
Got it thanks.
--
Posted via http://www.ruby-forum.com/.