Mega Code Archive

 
Categories / Ruby / Array
 

To change an element, you can simply assign it a new value or manipulate it

x = [1, 2, 3, 4] x[2] += 1 puts x[2]