Values & References8 / 16
Up next

Immutable arguments are safe

// given an immutable List, the callee cannot alter the original
def withExtra(xs: List[Int]): List[Int] =
  xs :+ 99

@main def main(): Unit =
  val original = List(1, 2)
  val result = withExtra(original)
  println(s"$original $result")
What you're solving

the caller's value cannot change