3

The program successfully prints the 3,1,2 but I am curious about why it says that this expression is unused?

package Collection

object basics {

  def main(args: Array[String]): Unit = {
    var res = List[Int](1, 2)
    res.::=(3) // Unused expression without side effects 
    println(res.mkString(","))
  }
}
Tomer Shetah
  • 8,413
  • 7
  • 27
  • 35
cnidaye
  • 103
  • 6

2 Answers2

0

Perhaps some IntelliJ bug, that thinks it's just :: - pre-pend method invocation without assignment result to var. Next construction with post-fix annotation works for me well: res ::= 3

enter image description here

Dharman
  • 30,962
  • 25
  • 85
  • 135
Ivan Kurchenko
  • 4,043
  • 1
  • 11
  • 28
0

Issue was fixed and released in version 2020.3.20:

enter image description here

Tomer Shetah
  • 8,413
  • 7
  • 27
  • 35