GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  J2EE  >  Ruby
Go To First  |  Previous Question  |  Next Question 
 Ruby  |  Question 18 of 22    Print  
What is the use of global variable $ in Ruby?

  
Total Answers and Comments: 1 Last Update: August 18, 2007     Asked by: nancyphilips 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
August 18, 2007 04:59:44   #1  
Manikandan Mca        

RE: What is the use of global variable $ in Ruby?
If you declare one variable as global we can access any where, where as class variable visibility only in the class 
Example
class Test
def h
  $a = 5
  @b = 4
 
while $a > 0
puts $a
$a= $a - 1
end
end
end
test = Test.new
test.h
puts $a                     # 5
puts @b                    #nil

 
Is this answer useful? Yes | No

 Related Questions

View Question | Asked by : Tarique A.K.

Latest Answer : Classes,Objects,Inheritance,Singleton methods,polymorphism(accomplished by over riding and  overloading) are some oo concepts  supported by ruby. ...

Latest Answer : Ruby is supported by windows and linux. ...

Latest Answer : Iterator is handled using keyword 'each' in ruby.For example $no=[1,2,3]then we can use iterator as$no.each do |l|puts lendAbove prints the values of an array $no which is accomplished using iterator. ...
Read Answers (1) | Asked by : Robert

Latest Answer : A new scope for a local variable is introduced in the toplevel, a class (module) definition, a method defintion. In a procedure block a new scope is introduced but you can access to a local variable outside the block. The scope in a block is special ...
Read Answers (1) | Asked by : Robert

View Question | Asked by : Robert

View Question | Asked by : StephenRaj

Latest Answer : for..in untill..end while..end do..end ...

Latest Answer : Don't forget the funky ones like a   b, which returns 1 if a > b, 0 if a = b and -1 if a < b. ...

View Question | Asked by : StephenRaj


 Sponsored Links

 
Related Articles

What happens when a variable is not initialized in main function?

When a variable is not initialized in main function it contains garbage value. This can be well seen from the example below main() { int x; printf(&ldquo;%d&rdquo;,x); z= sample() } sample() { printf(&ldquo;Testing program&rdquo;); } Output is &nbsp;&nbsp;&n
 

What happens when a variable is not declared in function definition?

Generally in C program the function definition and calling takes the form as given below: main() { int x,y,z; z=sample(x,y); printf(&ldquo;%d&rdquo;,z); } sample(x1,y1) int x1,y1; { int z1; z1= x1 - y1; return(z1); } Here what happens is the values x, y gets passed to x1,y1
 

The Interview Snafu

How to turn someone else&rsquo;s mistake to your advantage Your dream job is about to become reality. A recruiter gave you the heads up about the perfect position at Humungous Conglomerate, Inc. You went through five interviews as well as a battery of psychological tests mandated by their HR de
 

Ruby on Rails Hype

Ruby on Rails Proves it Deserves the Hype With the multitude of programming languages out there such as Fortran, Java, C++ and C#, you may wonder why Ruby on Rails has suddenly become such a hot topic in the development world. Created in the late by an individual in Japan, the Ruby programming lang
 

Winning a Job Interview with a Winning Resume

Does your resume unlock your potential, take your skills to the highest level and win you the interview and the job you want now? The job market today is highly competitive and even if you think you have what it takes to get an interview you won&rsquo;t get over the line without a polished, prof
 

Importance of Proper English during Job Interview

Importance of Proper English during Job Interview Your job interview is crucially important and it will determine whether or not you will get the job Depending on the type of job you re going for it is very important for you to use proper English In most cases jobs which offer higher salaries will h
 

Increase your Job Outlook on Global Scale

Increase your Job Outlook on Global Scale The advent of both globalization and outsourcing are factors that are changing the world These elements have allowed the world to become much more interconnected and the differences between cultures which existed in the past have largely been reduced While m
 

Variable, Constants and Data types in C++

Variable Constants and Data types in C In this C tutorial you will learn about variable constants and data types in C rules for defining variable name short int int long int float double long double char bool declaring variables and constants mosgoogle Variables A variable is the storage location in
 

HR Interview - HR Interview Mistakes You Will Want To Avoid

HR Interview Mistakes You Will Want To Avoid The job interview can be a stressful process This is especially true for those who are going after a competitive position Your nonverbal communication combined with the answers you give during the interview will determine if you are hired mosgoogle While
 

HR Interview - Behavioral HR Interviews

Behavioral HR Interviews As the name implies a behavioral interview is an interview that is held by a human resources department to determine if an applicant has the behaviors that are appropriate for a job The company must know how an applicant will behave in a certain situations mosgoogle The logi
 

Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape