Could anyone explain what is faster for reading, writing in Ruby: an Array
or a Hash
? And what are the usecases for Array
and Hash
?
Array.new
Hash.new
If you need to store only some unique unordered values, please consider using Set.new
. It's convenient hash based class with writing and reading in constant time.
For reading and writing Hash.new
is faster than Array.new
. Watch this Why Hashes Will Be Faster in Ruby 2.0
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With