collections - Splitting out 3 or more Arrays in Scala -


Martin Oersky gives this example to divide an array into 2 collections:

   

What's the best way to divide into 3 or more arrays:

Val (minors, adults, senior) = people split ?? X & lt; 18, 18 & lt; X & lt; 65, X & gt; 65 /?

It may be less beautiful to do with one-liner. Wal (Minors, Older) = People Partition {_.age & lt; 18} Val (adult, senior) = old division {_.age

Comments