Casting the Result of splitter() into a string array

Jonathan M Davis jmdavisProg at gmx.com
Sun Jun 17 05:33:27 PDT 2012


On Sunday, June 17, 2012 14:11:27 GreatEmerald wrote:
> On Sunday, 17 June 2012 at 11:58:58 UTC, Jonathan M Davis wrote:
> > splitter(" a b ") is going to return a range of strings. If you
> > were to do
> > array(splitter("a b ")), you'd get ["", "a", "b"].
> 
> Aha, that worked! Thanks!
> 
> Still makes me wonder how you're supposed to figure out that this
> type is a range and not anything else from the library
> documentation, though... Oh well.

The documentation says so in most cases. It certainly does for filter. It is 
true that it doesn't for spliter though. But pretty much everything in 
std.algorithm and std.range take and return ranges. And std.array generally 
takes arrays and returns either arrays or ranges.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list