What is the difference between symbol and string?

Technology CommunityCategory: Ruby on RailsWhat is the difference between symbol and string?
VietMX Staff asked 3 years ago
  • Symbols have two nice properties compared to strings which can save you memory and CPU time The difference remains in the object_id, memory and process time for both of them when used together at one time
  • Strings are considered as mutable objects. Whereas, symbols, belongs to the category of immutable Strings objects are mutable so that it takes only the assignments to change the object information. Whereas, information of, immutable objects gets overwritten.