Why does '////'.split('/') produce []?
ruby
Solution
This design provides a convenience for parsing strings with trailing delimiters. For example:
`'1␣2␣3␣␣'.split('␣')` will now give `['1', '2', '3']` rather than `['1', '2', '3', '', '']`.
This feature is just for simplification of workflow.
However, I don't like this feature because it breaks the purity of this method. To achieve the effect above, you just need an extra `rstrip('␣')` between `'1␣2␣3␣␣'` and `split('␣')`.
Problem
The code `'////'.split('/')` results in `[]`. While I expected it to be `['', '', '', '', '']`. If this is a feature of ruby, why is it designed like so?