How to make rsplit (like in Python) in D

pineapple via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Oct 3 12:32:54 PDT 2016


On Monday, 3 October 2016 at 19:25:59 UTC, Uranuz wrote:
> When I pass empty string to splitter in most of languages I 
> expect to get list with 1 item (empty string) as a result, but 
> I get error instead. And I see inconsistency in that .front 
> behaves normally, but .back is not. Usually I access front of 
> range directly without any check when I expect it to have 
> exactly 1 item. But in this case it not working and is very 
> strange.

Hm, if front works but not back that is probably a bug.

I think checking whether the range is empty before accessing the 
member should be a viable workaround.


More information about the Digitalmars-d-learn mailing list