Re: define and call methods in ruby
- From: Ron Fox <fox@xxxxxxxxxxxx>
- Date: Mon, 15 Sep 2008 06:45:51 -0400
Jay Pangmi wrote:
maybe I'm wrong. but what I'm saying is (Here's what I do in java)
public class myclass
{
.....
String name;
static int i=0;
//defining a instance method
public void setName(String name)
{
this.name=name;
}
//defining the method.
public void printMessage()
{
System.out.println("Message");
}
//for some event
public void actionPerformed(ActionEvent e)
{
if (e.getSource()==xxxx)
{
printMessage(); //declaring a method in the same class.
}
}
........
}
public class anotherclass extends myclass
{
myclass mc;
int j;
..............
mc.setName("James"); //calls method with the instance of the class
j=myclass.i; //here coz i belongs to class.
}
Hope, it clears out what I'm trying to do. Just example, not very good in java either...
So, what I'm trying to do is declare similar method as printMessage() in ruby. thanks
A mantra for you.. Ruby is not Java repeat 100 times until you believe it. Then start learning Ruby all over again with a beginner's mind. Java is compiled, Ruby interpreted. Ruby knows nothing of your display method until it sees it.. see my previous post.
R
--
Ron Fox
NSCL
Michigan State University
East Lansing, MI 48824-1321
.
- References:
- define and call methods in ruby
- From: Jay Pangmi
- Re: define and call methods in ruby
- From: David A. Black
- Re: define and call methods in ruby
- From: Jay Pangmi
- Re: define and call methods in ruby
- From: DanDiebolt.exe
- Re: define and call methods in ruby
- From: Jay Pangmi
- define and call methods in ruby
- Prev by Date: Re: define and call methods in ruby
- Next by Date: Thread popen and broken pipe problem
- Previous by thread: Re: define and call methods in ruby
- Next by thread: Re: define and call methods in ruby
- Index(es):
Relevant Pages
|