Pre SIP: Named tuples

A practical aspect: I assume returning a named tuple is going to be very common. Within the implementation one might not want to deal with the element names.

  def m(xs: List[Int]): (sum: Int, log: String) = {
    val r = xs.foldLeft((0, "")) {
      case ((acc, d), x) => (acc + x, s"$d$x")
    }
    // some work with `r`
    r
  }

unnamed <: named allows the above without the runtime cost of a conversion.

4 Likes