Ruby

37
1281 reads

March 4, 2013

SINGLETON CLASS METHODS


Ways of defining class methods

26
1200 reads

March 4, 2013

Instance Variables


Understand how a class may have instance variables

40
1267 reads

March 4, 2013

Class Methods


An instance method belongs to a specific instance of a class – in other words, to an individual object. It is also possible to write ‘class methods’. A class method belongs to the class itself.

21
1218 reads

March 4, 2013

Class_hierarchy


All Ruby objects are descendents of the Object class... ...and that includes the Class class!

35
1327 reads

March 4, 2013

Singleton Method


A singleton method is a method which belong to a single object rather than to an entire class. Many of the methods in the Ruby class library are singleton me-thods.

34
1241 reads

March 1, 2013

MultiArray


for loop to iterate over all the items in each sub-array individually

29
1410 reads

March 1, 2013

Multidimensional Array


Array inside an array

36
1279 reads

March 1, 2013

Copying a Hash


As with an array, you can assign one Hash variable to another, in which case both variables will refer to the same Hash and a change made using either variable will affect that Hash

24
1166 reads

March 1, 2013

Creating Hashes


Just like an array, you can create a hash by creating a new instance of the Hash class:
h1 = Hash.new
h2 = Hash.new("Some kind of ring")

35
1281 reads

March 1, 2013

Sorting Hash


As with the Array class, you may find a slight problem with the sort method of Hash.