Posted in Ruby, coding on Mar 22nd, 2008 No Comments »
person = “Tim”
p person.object_id
p person.class
p person
#~ 22901710
#~ String
#~ “Tim”
- Ruby creates a new String object with the value “Tim”
- A reference to this object is placed in the local variable person.
- The o/p revels this variable(person) has indeed taken on the personality of a string, with an object id, a type, and a […]
Read Full Post »
Posted in Ruby on Mar 22nd, 2008 No Comments »
-Ruby has three kinds of variables:
Global variables
Instance variables
Local variable
-Constant
e.g GVAL = “9.8′
-And two pseudo-variables.
self
nil
self, which always refers to the currently executing object, and nil, which is the meaningless value assigned to uninitialized variables. Both are named as if they are local variables, but self is a global variable maintained by the interpreter, and nil is […]
Read Full Post »