3 ms·
Well of course, if you look at "mathy" operators like +. If you look at operator[], the use cases are all "collectiony" objects instead.
by edflsafoiewq 6y ago
Well of course, if you look at "mathy" operators like +. If you look at operator[], the use cases are all "collectiony" objects instead.
- AnimalMuppet 6y agoI could even see + on collections: "Add all the elements of this collection to that collection."
- erik_seaberg 6y agoScala used + for an element and ++ for another collection scala> 1 +: List(2, 3) ++: List(4, 5) :+ 6 res0: List[Int] = List(1, 2, 3, 4, 5, 6) where +: is right-associative and implemented by the list rather than the element.
- joshuamorton 6y agoAnd note that these overlap: think matrices where a + b adds, and a[1:,:,0] may have meaning, requiring the index operator to support tuples and range objects.