ruby - Can I access a private class method from a public instance method without using the class name? -


i have class method, self.calculate, want invoke both class method , instance method.

if write

def green   calculate(x,y,z) end 

though, nomethoderror: undefined method 'calculate' exception. invoking self.calculate gets same problem.

what does work calling myclassname.calculate, seems somehow wrong , messy. correct practice in situation?

you can use

self.class.calculate 

to call class methods instance method.


Popular posts from this blog