Câu hỏi phỏng vấn Ruby
Câu hỏi

Can you call a private method outside a Ruby class using its object?

Câu trả lời

No, you cannot call a private method outside a Ruby class using its object. In Ruby, private methods are restricted to being called only within the context of the class in which they are defined. This means they can only be called by other instance methods within the same class or its subclasses, but not with an explicit receiver, which includes the object itself[1][2][3][4].

Citations:
[1] https://www.rubyguides.com/2018/10/method-visibili...

junior

junior

Gợi ý câu hỏi phỏng vấn

middle

Why can you safely use a string as a hash key, even though a string is mutable?

junior

Is Ruby a statically typed or a dynamically typed language?

senior

Is a method an object?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào