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

What Is The Difference Between Nil And False In Ruby?

Câu trả lời

The main differences between nil and false in Ruby are:

  • nil represents the absence of a value, while false is a boolean value representing falsehood[1][2][3].
  • nil is an object of the NilClass, while false is an object of the FalseClass[1][2][3].
  • When Ruby expects a boolean value, nil is treated as false, but nil is not strictly equal to false because they are different classes[1][2][3].
  • All values in Ruby except false and nil are considered "truthy" and evaluate to true in a boolean context[4][5].
  • You can check if a value is nil using the nil? method, which returns true for nil and false for all o...
junior

junior

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

senior

What is Rack?

senior

What are Strong Parameters?

junior

Explain how you define Instance Variable, Global Variable and Class Variable in Ruby?

Bình luận

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

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