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

What does a bang ! at the end of a method signify?

Câu trả lời

In Ruby programming, a bang ! at the end of a method name signifies that the method is a "bang method," which means it modifies the object it is called on directly. Unlike their non-bang counterparts, bang methods perform operations that alter the state of the object instead of returning a new object with the modifications. For example, if you use downcase! on a string, it will convert the string to lowercase and change the original string itself, rather than just returning a new lowercase version[1]. This is in contrast to the regular downcase method, which returns a new string in lowercase without altering the original string. It's important to use bang method...

middle

middle

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

junior

What does it mean to coerce an object? Why would you do it?

middle

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

senior

What is the difference between Object#dup and #clone ?

Bình luận

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

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