Mega Code Archive

 
Categories / Ruby / Array
 

Push integer and string to the same array

a = [1, 2, 3]                           # => [1, 2, 3] p a << 4.0                                # => [1, 2, 3, 4.0] p a << 'five'                             # => [1, 2, 3, 4.0, "five"]