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

What is the difference between symbol and string ?

Câu trả lời

Here is an explanation of the difference between symbols and strings in Ruby on Rails:

Symbols vs Strings

In Ruby, both symbols and strings are used to represent text, but they have some key differences:

Memory Usage

  • Strings are mutable and can be modified after creation. Each string takes up a unique block of memory.
  • Symbols are immutable and always have the same object ID. Ruby only stores one copy of each symbol in memory.

Equality

  • Two strings are only equal if they have the same characters, even if they look the same.
  • Two symbols are only equal if they have the same name, even if they look differ...
middle

middle

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

middle

Mention what is the difference between the Observers and Callbacks in Ruby on Rails?

middle

What Is The Difference Between Delete And Destroy ?

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