Home:ALL Converter>Getting MatchError when using a placeholder for an unused variable

Getting MatchError when using a placeholder for an unused variable

Ask Time:2020-09-02T16:34:36         Author:himanshuIIITian

Json Formatter

With Scala 2.13.x, I am getting scala.MatchError: null when I use a placeholder for an unused variable:

scala> object Test {
     |   val _: Any = null
     | }
object Test

scala> Test
scala.MatchError: null
  ... 41 elided

But with Scala 2.12.x, I am not getting scala.MatchError: null:

scala> object Test {
     |   val _: Any = null
     | }
defined object Test

scala> Test
res1: Test.type = Test$@784c5ef5

Any reason?

Author:himanshuIIITian,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/63701707/getting-matcherror-when-using-a-placeholder-for-an-unused-variable
yy