This is probably intended behavior rather than a bug. According to the documentation, splitting an array:
Divides the array into one or more subarrays based on a delimiting value or the result of an optional block.
This makes no guarantees about contiguous or leading spaces.
On the other hand, the Ruby core documentation for String#split
states:
If pattern is a String, then its contents are used as the delimiter when splitting str. If pattern is a single space, str is split on whitespace, with leading whitespace and runs of contiguous whitespace characters ignored.
As you can see, the behavior you expect only works with whitespace, not for just any string.
"abc ccc def ".split("c")
=> ["ab", " ", "", "", " def "]
When splitting an array, the concept of "whitespace" doesn't really make sense any more. So I think the behavior is sensible, if perhaps counterintuitive at first.