Parv_G
(Parv G)
1
Hi,
Newbie Question:
How do i invoke a method in belonging to a module?
For Example:
···
###############
#file: SampleModule.rb
Module SampleModule
def add(a, b)
return a + b
end
def multiply(a, b)
return a * b
end
end
################
#file: test.rb
require 'SampleModule.rb'
#here i would like to make a call to add() method of Module SampleModule
(sitting in file: SampleModule.rb)
help??
--
Posted via http://www.ruby-forum.com/.
Parv_G
(Parv G)
2
this seems to work:
SampleModule::add(2, 3)
so i think i'm ok for now.
Thanks.
···
--
Posted via http://www.ruby-forum.com/.
add this lile:
include "SampleModule"
then you can use the add, multiply normally.
···
----- Original Message -----
From: "Parv G."
Date: Tuesday, December 5, 2006 12:48 pm
Subject: Invoking a Method
To: ruby-talk@ruby-lang.org (ruby-talk ML)
Hi,
Newbie Question:
How do i invoke a method in belonging to a module?
For Example:
###############
#file: SampleModule.rb
Module SampleModule
def add(a, b)
return a + b
end
def multiply(a, b)
return a * b
end
end
################
#file: test.rb
require 'SampleModule.rb'
#here i would like to make a call to add() method of Module
SampleModule(sitting in file: SampleModule.rb)
help??
--
Posted via http://www.ruby-forum.com/\.