'Groovy: Why does split()ing an empty string by space return a list of one empty string?
I was expecting an empty list but I got:
assert 1 == "".split(/\s+/).size()
and
assert 0 == "".split().size()
Solution 1:[1]
Maybe you should use tokenize() instead?
assert "".tokenize().size() == 0
assert "foo bar".tokenize() == ['foo', 'bar']
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dónal |
