foobar
A variable whose name begins with a lowercase letter (a-z) or underscore (_) is a local variable.@foobar
A variable whose name begins with '@' is an instance variable of self.
@@foobar
A class variable is shared by all instances of a class.$foobar
A variable whose name begins with '$' has a global scope; meaning it can be accessed from anywhere within the program during runtime.FOOBAR
A variable whose name begins with an uppercase letter (A-Z) is a constant. A constant can be reassigned a value after its initialization, but doing so will generate a warning,More detailed information about Ruby constants and variables can be found from here:
http://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Variables_and_Constants
No comments:
Post a Comment