ClearMyBench
Welcome, Guest
Please Login or Register.    Lost Password?
Re:Ruby basics (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Re:Ruby basics
#4373
ShriNi (User)
Software Techie (PEGA) currently on a Career Break
Platinum Boarder
Posts: 4000
graph
User Offline Click here to see the profile of this user
Gender: Female Location: Secundrabad India Birthdate: 1983-09-29
Re:Ruby basics 3 Years, 10 Months ago Karma: 0  
Instance Variables:

Instance variables are available across methods for any particular instance or object.

That means that instance variables change from object to object. In

stance variables are preceded by the at sign (@) followed by the variable name.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4374
ShriNi (User)
Software Techie (PEGA) currently on a Career Break
Platinum Boarder
Posts: 4000
graph
User Offline Click here to see the profile of this user
Gender: Female Location: Secundrabad India Birthdate: 1983-09-29
Re:Ruby basics 3 Years, 10 Months ago Karma: 0  
Class Variables:

Class variables are available across different objects.

A class variable belongs to the class and is a characteristic of a class.

They are preceded by the sign @@ and are followed by the variable name
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4375
ShriNi (User)
Software Techie (PEGA) currently on a Career Break
Platinum Boarder
Posts: 4000
graph
User Offline Click here to see the profile of this user
Gender: Female Location: Secundrabad India Birthdate: 1983-09-29
Re:Ruby basics 3 Years, 10 Months ago Karma: 0  
Global Variables:

Class variables are not available across classes.

If we want to have a single variable, which is available across classes, we need to define a global variable

. The global variables are always preceded by the dollar sign ($).
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4376
ShriNi (User)
Software Techie (PEGA) currently on a Career Break
Platinum Boarder
Posts: 4000
graph
User Offline Click here to see the profile of this user
Gender: Female Location: Secundrabad India Birthdate: 1983-09-29
Re:Ruby basics 3 Years, 10 Months ago Karma: 0  
Let's consider an example

Using the class variable @@no_of_customers, we can determine the number of objects that are being created.

This enables in deriving the number of customers.

class Customer
@@no_of_customers=0
end
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4377
ShriNi (User)
Software Techie (PEGA) currently on a Career Break
Platinum Boarder
Posts: 4000
graph
User Offline Click here to see the profile of this user
Gender: Female Location: Secundrabad India Birthdate: 1983-09-29
Re:Ruby basics 3 Years, 10 Months ago Karma: 0  
Objects are instances of the class. .

We can create objects in Ruby by using the method new of the class.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4378
ShriNi (User)
Software Techie (PEGA) currently on a Career Break
Platinum Boarder
Posts: 4000
graph
User Offline Click here to see the profile of this user
Gender: Female Location: Secundrabad India Birthdate: 1983-09-29
Re:Ruby basics 3 Years, 10 Months ago Karma: 0  
The method new is a unique type of method, which is predefined in the Ruby library.

The new method belongs to the class methods.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply
get the latest posts directly to your desktop
logo footer   Copyright 2009 - 2013 HotRecruiter.Com - All Rights Reserved