Ruby

39
1295 reads

March 1, 2013

Hash Order


Hash Order

23
1242 reads

March 1, 2013

Treating Hashes as Arrays


The keys and values methods of Hash each return an array so you can use various Array methods to manipulate them.

35
1260 reads

March 1, 2013

Hash Methods


The Hash class has numerous built-in methods. For example, to delete an item using its key ( someKey ) from a hash, aHash, use aHash.delete( someKey ).

23
1371 reads

March 1, 2013

Flatten and Compact


Flatten and Compact Methods

27
1193 reads

March 1, 2013

Comparisons Module


The comparison ‘operator’ <=> (which is, in fact, a method) is defined in the Ruby module named Comparable. For now, you can think of a module as a sort of reusable ‘code library’.

23
1298 reads

March 1, 2013

Array Getting Started


An Array is a sequential collection of items in which each item can be indexed.

25
1288 reads

March 1, 2013

Array Sorting


# you can pass a block to the sort method of Array to determine how two consecutive elements are

374
2709 reads

March 1, 2013

Array Methods


Various array methods

22
1164 reads

March 1, 2013

Compare the array length


Compare the length of two arrays.

38
1402 reads

March 1, 2013

Array Index


As with strings , you can index from the end of an array using minus figures, where -1 is the index of the last element; and you can also use ranges