fastruby / fast-ruby

:dash: Writing Fast Ruby :heart_eyes: -- Collect Common Ruby idioms.
https://github.com/fastruby/fast-ruby
5.67k stars 376 forks source link

Array#first vs Array#[](0) and Array#last vs Array#(-1) #32

Closed vpereira closed 9 years ago

vpereira commented 9 years ago

first and last are slower then using index. For example in Rubinius, it returns a new array (Array.new[0, n]) while array[idx] returns a Rubinius.primitive :array_new_range

JuanitoFatas commented 9 years ago

Thanks! I've committed your Pull Request with some minor fixes as 0184134. Awesome work :+1:!