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

senior

Is Rails Scalable?

junior

What Is MVC? And How It Works?

middle

Mention what is the purpose of RJs in Rails?

Bình luận

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

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