Ruby

38
1276 reads

January 24, 2013

Reverse array elements


This code shows how to reverse the order of elements in an array.

351
3283 reads

January 24, 2013

Sort an array


Make sure the elements are comparable and sort! will handle the rest.

282
3993 reads

January 24, 2013

Delete an array element


Use the delete method to delete a particular array element.

183
2047 reads

January 24, 2013

Insert a value in an array


Insert an element into an array at a given position.

356
4598 reads

January 24, 2013

Clear all array elelments


This code shows how to delete all elements of an array.

125
2204 reads

January 24, 2013

Concat


This concatenated q3 and q4, make a new array, last_part. Concat always returns a new array, it does not add elements to an existing array the way << does.

92
1460 reads

January 24, 2013

Concatenate arrays


This code shows how to concatenate two arrays using '+' operator and '<<' operator.

150
2507 reads

January 24, 2013

Check if element exists in an array


To check if a given element exists in an array.

113
1176 reads

January 24, 2013

Indexing in arrays


This code shows how to use indexes in arrays to access array elements.

374
3323 reads

January 24, 2013

Accessing Elements of Array


This code shows how to access array elements in two different ways.