Practical examples of using symbols in Scala?

前端 未结 8 2160
借酒劲吻你
借酒劲吻你 2020-12-07 19:46

Scala has symbols - names that start with a single quote \' and which are a kind of string constants.

I know symbols from Ruby (where they start with a colon). In Ru

8条回答
  •  星月不相逢
    2020-12-07 20:43

    I believe comparisons between symbols is faster. If you've used Erlang, symbols are used a tonne when passing around messages and you want something cheap, and fast, that works well ACROSS machine boundaries. I'm not sure in what state remote actors are in Scala, IIRC, they were rather dodgy, but in the future when them in place, symbols could well be very useful in much the same way as they are in Erlang. Also case classes, some of the benefits aren't as apparent, then again, symbols are still cheaper.

提交回复
热议问题