Filtering empty arrays from array of arrays in Scala

Viewed 8748

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.

4 Answers
Related