gather / scatter for Scala