Comptuer Studies Ruby Notes

Topics: Perl, Variable, Subroutine Pages: 4 (838 words) Published: March 25, 2013
These are notes I took while I was learning Ruby.
Comptuer studies ruby notes
Instance of a class is a sub-category of that class. E.g. greyhound; dog. Every object has a class. Objects are instances of classes. Methods define what an object can do and properties describe it. Constants start with a capital letter, sometimes they are all caps e.g. INTEREST = 0.012 #setting constant INTEREST to 1.2%

DOZEN = 12 #setting constant DOZEN to 12
Constants and variables store information in the memory for the duration of the use of the program. Like RAM? Constants can’t be changed but variables can be reassigned based on certain properties and data. Different types of classes:

ClassExample of Object
Float6.5 or 3.9
Fixnum2 or 3
StringThisisastring or randomnumber34
HashToronto [Dion Phaneuf]
Pittsburgh [Sidney Crosby]
Washington [Alex Ovechkin]
Haseeb [November 18]
Humza [August 6]
Hana [August 11]

Float = decimal number
Fixnum/Integer = whole number
String = letters and numbers
Array = an ordered list, a couple of objects put together in one list that can also be accessed independently Create a new array or reset an old one by using this:
array =
You can also show individual variables by doing:
array[number] e.g.
you can also add objects to the array by:
subjects [4] = ‘Social Science’
Hash = Similar to array but not in order, each object does not have a number. It’s based on key and value pairs. Like if you put five names and assigned each a birthday. They would go based on those pairs. It assigns the first name to the second. E.g: friends =

friends['Andrea'] = 'July 22'
friends['Mohammed'] = 'April 9'

Range = A sequence of values e.g. nums = 11..20
Setting variable:
Fav_food = ‘pizza’ #setting variable fav_food to pizza
The quote marks around pizza identify that fav_food is a...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • 1263788094 2009 Studies of Religion Notes Essay
  • study notes Essay
  • Study Notes Essay
  • Essay about Study Notes
  • Study Notes Research Paper
  • Study Notes Essay
  • study notes Essay
  • Of Studies Notes Essay

Become a StudyMode Member

Sign Up - It's Free