This won’t work for what you want; for example try the input [[], []]. Modifying a collection while iterating over it is often unsafe and you should think carefully about it when you do.
b.reject(_.isEmpty). I recommend familiarizing yourself with the interfaces of Collection, SequenceableCollection, and ArrayedCollection.