silly question

F

Ferenc Engard

Hi all,

Sorry that I am asking so trivial, maybe it is too late: can I somehow
mix in module functions into a module or a class? I.e.,

module X
def X.foo; puts "foo"; end
end

module Y
include X # what to write here?
def bar; foo(); end # want to call X.foo
end

Is it even make sense?

In fact, I used ncurses library with ruby 1.6.8, and there I could use
Ncurses methods like in the example above. With the new libs I cannot do
that. Maybe in the old library the Ncurses methods were module AND
instance methods...?

Thanks,
Ferenc
 
N

nobu.nokada

Hi,

At Mon, 30 Aug 2004 09:29:04 +0900,
Ferenc Engard wrote in [ruby-talk:110908]:
That description deals with normal mixin functionality, using instance
methods. Here I want to use a module method in another module (or class)
without qualifying it.

X.foo isn't an instance method but a singleton method of X,
that is, it's defined for nothing but X. So you can never call
it without X.
 
N

nobu.nokada

Hi,

At Mon, 30 Aug 2004 08:29:01 +0900,
Ferenc Engard wrote in [ruby-talk:110906]:
 
T

T. Onoma

Sorry that I am asking so trivial, maybe it is too late: can I somehow
mix in module functions into a module or a class? I.e.,

For more info see Ruby-Talk:109274.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,156
Messages
2,570,878
Members
47,408
Latest member
AlenaRay88

Latest Threads

Top