DEV Community

Discussion on: In-Place Algorithms; what are they, and why use them?

Collapse
 
hminaya profile image
Hector Minaya

Not everything is as it seems, in Ruby you can add elements dynamically to an array, which in reality just creates a new Array (based on the new size) and may keep the old one around until the garbage collector disposes of it.

Even JS has the ability to add/remove elements from an Array, because it's actually not an Array. It's a dictionary with an integer key and an object as it's value.