Ron Fox
9/15/2008 10:46:00 AM
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