R
rtilley
I'm trying to better understand how variables are named in Ruby...
here's what I think I understand. Please correct me where I misunderstand:
#Globals are defined outside a class/method and are
#available everywhere. Must starts with '$'
$global_variable
#Class names must start with capitalized letter.
class Class_name
#Starts with '@@' and is available to all methods in the class.
@@class_variable
#Method name must start with lowercase letter or '_'
def method_name
#Must start with '@' similar to Python's self notation.
#This variable is local to the method.
@method_variable
end
end
Where do constants and local variables fit into this?
Thanks,
Brad
here's what I think I understand. Please correct me where I misunderstand:
#Globals are defined outside a class/method and are
#available everywhere. Must starts with '$'
$global_variable
#Class names must start with capitalized letter.
class Class_name
#Starts with '@@' and is available to all methods in the class.
@@class_variable
#Method name must start with lowercase letter or '_'
def method_name
#Must start with '@' similar to Python's self notation.
#This variable is local to the method.
@method_variable
end
end
Where do constants and local variables fit into this?
Thanks,
Brad