What's the difference between a string and a symbol in Ruby?

后端 未结 10 1303
说谎
说谎 2020-11-28 06:52

What\'s the difference between a string and a symbol in Ruby and when should I use one over the other?

10条回答
  •  無奈伤痛
    2020-11-28 07:27

    Strings are Mutable , Symbols arre immutable
    Note:Mutable objects can be changed after assignment while immutable objects can only be overwritten http://www.robertsosinski.com/2009/01/11/the-difference-between-ruby-symbols-and-strings/

提交回复
热议问题