2503ICT: Rails-oriented Ruby


Under construction!

References

The chapter in Hartl's book is a very good introduction.

Miscellaneous features

In class definitions, variables of the form name are local variables of methods, variables of the form @name are instance variables of the class (i.e., fields of class instances), and variables of the form @@name are class variables (i.e., properties of the class). Names of the form NAME are constants.

Again in a definition of a class Item, say, method definitions that start

def Item.name
 ...
end

or

def self.name
  ...
end

are class or static methods.

Assignments in methods of the form self.var = value are assignments to the field var of the current instance. Assignments in methods of the form var = value are assignments to the local variable var.