How is pattern matching in Scala implemented at the bytecode level?

后端 未结 4 1184
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-04 06:24

How is pattern matching in Scala implemented at the bytecode level?

Is it like a series of if (x instanceof Foo) constructs, or something else? What are

4条回答
  •  一生所求
    2020-12-04 06:48

    Since version 2.8, Scala has had the @switch annotation. The goal is to ensure, that pattern matching will be compiled into tableswitch or lookupswitch instead of series of conditional if statements.

提交回复
热议问题