Answer the question
In order to leave comments, you need to log in
What is the difference between private_class_method and private?
What is the difference between private_class_method and private?
if you replace line 10 with this, private :new
it gives an error `private': undefined method `new' for class `Point3D'
class Point3D < Point
def initialize(x, y, z)
super(x, y)
@z = z
end
def self.fabric(x,y,z)
new(x,y,z)
end
private_class_method :new # если заменить на private :new
end
po1 = Point3D.fabric 4,6,5
p po1
Answer the question
In order to leave comments, you need to log in
apidock.com/ruby/Module/private_class_method
private_class_method makes a class method private (strange, isn't it?)
private with an argument - an object method (instance method)
The error is quite reasonable - there is no such instance method in the Point3D class, only a class method.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question