Scala: Can I use -= head to remove an item from a list?

273 views Asked by At

It appears that using i -= i.headdoes not perform the same function as i.remove(0) on a ListBuffer. Is that right. If so why?

1

There are 1 answers

0
jwvh On

i -= i.head returns the modified ListBuffer.

i.remove(0) returns the element removed from the ListBuffer.

The resulting modified ListBuffer is the same in either case.