diff --git a/std/array.d b/std/array.d index 8efb38b57bf..c7eb29675fe 100644 --- a/std/array.d +++ b/std/array.d @@ -1309,29 +1309,48 @@ Alias for $(XREF algorithm, splitter). deprecated("Please use std.algorithm.splitter instead.") alias splitter = std.algorithm.splitter; /++ -Eagerly splits $(D s) into an array, using $(D delim) as the delimiter. + Eagerly splits $(D range) into an array, using $(D sep) as the delimiter. -See_Also: $(XREF algorithm, splitter) for the lazy version of this operator. + The range must be a $(FULL_XREF std_range.html#isForwardRange, forward range). + The separator can be a value of the same type as the elements in $(D range) or + it can be another forward range. + + Examples: + If $(D range) is a $(D string), $(D sep) can be a $(D char) or another + $(D string). The return type will be an array of strings. If $(D range) is + an $(D int) array, $(D sep) can be an $(D int) or another $(D int) array. + The return type will be an array of $(D int) arrays. + + Params: + range = a forward range. + sep = a value of the same type as the elements of $(D range) or another + forward range. + + Returns: + An array containing the divided parts of $(D range). + + See_Also: + $(XREF algorithm, splitter) for the lazy version of this function. +/ -auto split(R, E)(R r, E delim) -if (isForwardRange!R && is(typeof(ElementType!R.init == E.init))) +auto split(Range, Separator)(Range range, Separator sep) +if (isForwardRange!Range && is(typeof(ElementType!Range.init == Separator.init))) { import std.algorithm : splitter; - return r.splitter(delim).array; + return range.splitter(sep).array; } ///ditto -auto split(R1, R2)(R1 r, R2 delim) -if (isForwardRange!R1 && isForwardRange!R2 && is(typeof(ElementType!R1.init == ElementType!R2.init))) +auto split(Range, Separator)(Range range, Separator sep) +if (isForwardRange!Range && isForwardRange!Separator && is(typeof(ElementType!Range.init == ElementType!Separator.init))) { import std.algorithm : splitter; - return r.splitter(delim).array; + return range.splitter(sep).array; } ///ditto -auto split(alias isTerminator, R)(R r) -if (isForwardRange!R && is(typeof(unaryFun!isTerminator(r.front)))) +auto split(alias isTerminator, Range)(Range range) +if (isForwardRange!Range && is(typeof(unaryFun!isTerminator(range.front)))) { import std.algorithm : splitter; - return r.splitter!isTerminator.array; + return range.splitter!isTerminator.array; } unittest