E
estebanjang
Hi,
In the following code, how can I call "Hello.jane" method?
class Hello
def Hello.jane
puts "I am jane"
end
private_class_method :jane
end
All the following generate NoMethodError:
[1] From within class body
class Hello
Hello.jane
end
[2] From another class method
class Hello
def Hello.call_jane
Hello.jane
end
end
Hello.call_jane
[3] From an instance
class Hello
def call_jane2
Hello.jane
end
end
a = Hello.new
a.call_jane2
Is there any context where I can call Hello.jane?
Also, I am using private_class_method, since the "private" keyword
doesn't seem to have any effect on class methods. Am I missing
something?
Thanks,
-Steve
In the following code, how can I call "Hello.jane" method?
class Hello
def Hello.jane
puts "I am jane"
end
private_class_method :jane
end
All the following generate NoMethodError:
[1] From within class body
class Hello
Hello.jane
end
[2] From another class method
class Hello
def Hello.call_jane
Hello.jane
end
end
Hello.call_jane
[3] From an instance
class Hello
def call_jane2
Hello.jane
end
end
a = Hello.new
a.call_jane2
Is there any context where I can call Hello.jane?
Also, I am using private_class_method, since the "private" keyword
doesn't seem to have any effect on class methods. Am I missing
something?
Thanks,
-Steve