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

What happens to a consta...

Câu trả lời

In Ruby, constants must be assigned a value when they are declared. If a constant is referenced without being assigned a value, Ruby will raise a "NameError" indicating an "uninitialized constant" [2][3]. This error occurs because Ruby constants are expected to be defined with a value before they are used. Unlike some other programming languages where constants or variables might be automatically initialized to a default value (like null or 0), Ruby requires explicit initialization of constants.

For example, attempting to use a constant without initializing it, like this:

puts MyConstant

will result in:

NameError: uninitialized constant MyConstant

This error message is Ruby's way of e...

senior

senior

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

middle

Can you tell me the three levels of method access control for classes and modules? What do they imply
about the method?

middle

Explain redo vs. retry usage

junior

Is Ruby a strongly typed or a weakly typed language?

Bình luận

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

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