scala: how to define a value class

后端 未结 1 343
时光说笑
时光说笑 2021-01-15 18:08

Quick question regrading how to define a value class in scala

Here is typical example:

class Wrapper(val underlying: Int) extends AnyVal
相关标签:
1条回答
  • 2021-01-15 18:25

    It seems you're doing

    class Foo {
      class Wrapper(val underlying: Int) extends AnyVal
    }
    

    which you can't. You have to do

    class Foo {
    }
    class Wrapper(val underlying: Int) extends AnyVal
    
    0 讨论(0)
提交回复
热议问题