include

  • Thread starter Alexander Fleck
  • Start date
A

Alexander Fleck

Hi,
is the Ruby-'include' equal to a C++-'using' statement? Meant for namespace issues. Or does it have a bigger result?
Thanks,
Alex.
 
C

Christophe Grandsire

Selon Alexander Fleck said:
Hi,
is the Ruby-'include' equal to a C++-'using' statement? Meant for names= pace
issues. Or does it have a bigger result?
Thanks,
Alex.

"include" is used to mix in a module into a class. It has nothing to do w=
ith
namespaces, but is rather a way to quickly add functionality to a class b=
eyond
what is given by its superclass without resorting to multiple inheritance=
 
R

Robert Klemme

Christophe said:
"include" is used to mix in a module into a class. It has nothing to
do with namespaces, but is rather a way to quickly add functionality
to a class beyond what is given by its superclass without resorting
to multiple inheritance=

Adding to that "extend" is more similar to "using". Using "extend" you
can make some things (i.e. methods) from a module directly available.

Kind regards

robert
 
C

Christophe Grandsire

Selon Robert Klemme said:
Adding to that "extend" is more similar to "using". Using "extend" you
can make some things (i.e. methods) from a module directly available.

Indeed. And if you defined module methods in the module, you can even cal=
l them
directly with the module name, without having to use "extend" to access t=
hem.

In other words, one can, and does, use modules for namespaces already. Yo=
u just
*don't* do that with "include", but rather without it :) .
--
Christophe Grandsire.

http://rainbow.conlang.free.fr

It takes a straight mind to create a twisted conlang.
 

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
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top