Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated to today

  • Loading branch information...
commit 493fdaa0c502ca4d7927f37222a5a4f5d6ffa488 1 parent 9ad6a89
Sayth authored
Showing with 21 additions and 1 deletion.
  1. +21 −1 Ruby.txt
22 Ruby.txt
View
@@ -7,7 +7,7 @@ Notes for Ruby These taken from pickaxe.
__ *Global*__ variables are prefixed with a $ sign
- *Instance* variables begin with an @ sign
+ *Instance* variables begin with an @ sign. Uninitialized instance variables have a value of nil.
*Class* variables begin with a @@ sign
@@ -43,5 +43,25 @@ there are 2 forms of @blocks
Dave says hello
Andy says goodbye
}}}
+*Classes and Objects*
+For instances of a class when created to contain information we want we need to set
+the variables in the class. Instances with @instance variables.
+
+{{{ruby class Something
+ def initialize(one, two)
+ @one = one
+ @two = two
+ end
+ end
+ }}}
+When you call Class.new to create a new object Ruby allocates some memory to hold an
+uninitialized Object and then calls that objects initialize method. Passing in any
+parameters that were passed to new. The parameters act like local variables within
+the method. we need to make them into instance variables so they survive.
+
+@instance variables are stored with each object and available to all instance members
+of those objects.
+
+*Attributes*are the way an object interacts with the real world. The visible components of an object.
Please sign in to comment.
Something went wrong with that request. Please try again.