using parse with string slice

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Dec 5 14:10:45 PST 2015


On Saturday, 5 December 2015 at 22:05:11 UTC, anonymous wrote:
> You can use std.conv.to instead or assign the slice to a 
> variable first.

This is a bit of a FAQ I think because people don't realize you 
can use to and parse to do the same thing.

The big difference is parse will advance the slice you pass it 
past the item it reads, whereas to will try to convert the entire 
input.

That's why parse wants a ref slice, so it can move it forward. 
But since you're slicing it yourself, to is the way to go.


More information about the Digitalmars-d-learn mailing list