I realize this perhaps a naive question but still I cant figure out how to call one method from another in a Ruby class.
i.e. In Ruby is it possible to do the following:
class A def met1 end def met2 met1 #call to previously defined method1 end end
Thanks,
RM
Those aren’t class methods, they are instance methods. You can call met1 from met2 in your example without a problem using an instance of the class:
Here is the equivalent using class methods which you create by prefixing the name of the method with its class name: