Why don't more projects use Ruby Symbols instead of Strings?

前端 未结 4 1474
南笙
南笙 2020-12-17 18:29

When I first started reading about and learning ruby, I read something about the power of ruby symbols over strings: symbols are stored in memory only once, while strings ar

4条回答
  •  我在风中等你
    2020-12-17 19:03

    In ruby, after creating the AST, each symbol is represented as a unique integer. Having symbols as hash keys makes the computing a lot faster, as the main operation is comparison.

提交回复
热议问题