What does the @elidable annotation do in Scala, and when should I use it?

前端 未结 3 554
鱼传尺愫
鱼传尺愫 2021-02-05 05:09

I\'ve noticed in some of the scala library code, notably Predef, there is code like:

/** Tests an expression, throwing an `AssertionError` if false.         


        
3条回答
  •  面向向阳花
    2021-02-05 05:32

    Actually, expressions can't just disappear, because they have a result. When you elide an invocation of a method of result type Boolean, you wind up with false, and so on.

    There was an issue a few months after this question was posted to settle what eliding Nothing does. The outcome was to elide to ???.

提交回复
热议问题