What’s the difference between a string and a symbol in Ruby?
The main difference is that multiple symbols representing a single value are identical whereas this is not true with strings. For example: irb(main):007:0> :test.object_id => 83618 irb(main):008:0> :test.object_id => 83618 irb(main):009:0> :test.object_id => 83618 Those are three references to the symbol :test, which are all the same object. irb(main):010:0> “test”.object_id => -605770378 irb(main):011:0> “test”.object_id => … Read more