To change three of the elements to have German rather than English spelling. : Array Elements « Array « Ruby






To change three of the elements to have German rather than English spelling.


# uses a range to change elements 5 through 7.

months = %w[ nil January February March April May June July August September October November December ]
months[5..7] = "Mai", "Juni", "Juli" 

 








Related examples in the same category

1.have an array that contains objects from different classes, not all just one type.
2.Accessing Elements
3.use the at method
4.Access the last element in the array
5.With -1, you access the last element in an array by looping back around with a negative number.
6.With start and length parameters
7.Replacing subarrays with []=
8.Change character case of an element