Values that leave the block

A value that leaves the block (the block's own result, a returned value, or a store into something that outlives it) is copied out before the arena is released, so the caller holds a copy.

So a function can stage its intermediate work in an arena and still return a result. The scratch strings map produced here go away with the block; the joined string the caller prints does not.

fn shout(names: [string]) -> string {
  context.allocator.use(.Arena)
  let loud = names.map(|name: string| name.to_upper())
  loud.join(" ")
}

fn main() {
  println(shout(["ada", "moon"]))
}
Output & diagnostics
Expected:
ADA MOON
Ctrl/⌘+Enter runs the current lesson.