Mega Code Archive

 
Categories / Ruby / Language Basics
 

Assign nil to array element

a = [ 1, 'cat', 3.14 ]   # array with three elements   a[0]   # set the third element   a[2] = nil   # dump out the array   p a