乐趣区

关于ruby:Ruby-实现-数组反转-Not-Reverse

Ruby 实现 Array#reverse 性能

    
def reverse(arrays)
  new_arrays = []

  index = arrays.size - 1
  while index >= 0
    new_arrays << arrays[index]
    index -= 1
  end

  new_arrays
end

退出移动版