I have an array of arrays of type String
, which looks something like:
[[""],["lorem ipsum", "foo", "bar"], [""], ["foo"]]
What I'd like to do is filter out all of the elements in the array that are themselves an empty array (where in this instance, by "empty array", I mean arrays that contain just an empty string), to leave me just with:
[["lorem ipsum", "foo", "bar"], ["foo"]]
However I'm struggling to find a way to do this (still new to Scala) - any help much appreciated!
Thanks.
Edit (with Rogach's simplification):
array.filterNot(_.forall(_.isEmpty))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With