The OpenD Programming Language

fill

Assigns value to each element of input range range.

Alternatively, instead of using a single value to fill the range, a filler forward range can be provided. The length of filler and range do not need to match, but filler must not be empty.

  1. void fill(Range range, Value value)
    void
    fill
    (
    Range
    Value
    )
    (
    auto ref Range range
    ,
    auto ref Value value
    )
    if (
    (
    isInputRange!Range &&
    is(typeof(range.front = value))
    ||
    isSomeChar!Value &&
    is(typeof(range[] = value))
    )
    )
  2. void fill(InputRange range, ForwardRange filler)

Parameters

range Range

An input range that exposes references to its elements and has assignable elements

value Value

Assigned to each element of range

Throws

If filler is empty.

Examples

int[] a = [ 1, 2, 3, 4 ];
fill(a, 5);
assert(a == [ 5, 5, 5, 5 ]);
int[] a = [ 1, 2, 3, 4, 5 ];
int[] b = [ 8, 9 ];
fill(a, b);
assert(a == [ 8, 9, 8, 9, 8 ]);

See Also

Meta