reverse

Reverses r in-place. Performs r.length / 2 evaluations of swap. UTF sequences consisting of multiple code units are preserved properly.

Range
reverse
(
Range
)
(
Range r
)
if (
isBidirectionalRange!Range &&
)

Parameters

r Range

a bidirectional range with either swappable elements, a random access range with a length member, or a narrow string

Return Value

Type: Range

r

Note: When passing a string with unicode modifiers on characters, such as \u0301, this function will not properly keep the position of the modifier. For example, reversing ba\u0301d ("bád") will result in d\u0301ab ("d́ab") instead of da\u0301b ("dáb").

Examples

int[] arr = [ 1, 2, 3 ];
assert(arr.reverse == [ 3, 2, 1 ]);
char[] arr = "hello\U00010143\u0100\U00010143".dup;
assert(arr.reverse == "\U00010143\u0100\U00010143olleh");

See Also

std.range.retro for a lazy reverse without changing r

Meta