albertodemichelis / squirrel

Official repository for the programming language Squirrel
http://www.squirrel-lang.org
MIT License
913 stars 156 forks source link

Add optional argument 'skipempty' to split function #209

Closed atanasovdaniel closed 4 years ago

atanasovdaniel commented 4 years ago

Current behavior threads all separators as important, as it is the case in CSV files. But for case where separators are just sequence of spaces 'split' returns unpredictable number of empty elements. In proposed implementation there is a optional argument (preserving original behavior) that will skip adding any empty element to resulting array.

Example of such input is: local a = split(" 123 456", " ") --> [ "", "", "123", "", "", "","456"] (default) local a = split(" 123 456", " ",true) --> [ "123","456"] (without empty elements)