mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
array: reverse empty arrays correctly
This commit is contained in:
@ -328,6 +328,9 @@ pub fn (a mut array) push_many(val voidptr, size int) {
|
||||
// array.reverse returns a new array with the elements of
|
||||
// the original array in reverse order.
|
||||
pub fn (a array) reverse() array {
|
||||
if a.len < 2 {
|
||||
return a
|
||||
}
|
||||
arr := array{
|
||||
len: a.len
|
||||
cap: a.cap
|
||||
|
Reference in New Issue
Block a user