In the expression below:

return matchAll(content, keywordsPattern)
            .map!(a => a.hit.stripLeft("[").strip("]"))
            .fold!((a, b) => a ~ "," ~ b)
            .splitter(',')
            .map!(a => a.stripLeft("\" ").strip("\" "))
.filter!(a => !a.any!(b => b == ' ' || b == '\\' || b == '/' || b == ':'))
            .array
            .sort
            .uniq;


fold is throwing an exception if the result of the previous map is empty. Is there any way to express something to convince fold to return the empty range received from map?

Of course, I know I can test for empty in a separate expression, but I'd like to keep my expression flow as it is.

Reply via email to