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

expert

How To Use Two Databases Into A Single Application?

senior

What is Rack?

middle

Mention what is the difference between calling super() and super call ?

Bình luận

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

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