My little test code below will not recognize the hash variable
if its first letter is not capitalized. If the first letter is
capitalized,
then everything is OK. I’ll appreciate any explanation for this
behavior.
===========================
failure if declared as “mc”. Must capitalize “M”, lowercase “m”
Am Fri, 10 May 2013 15:10:08 +0900
schrieb Phil L. [email protected]:
Hi, all:
My little test code below will not recognize the hash variable
if its first letter is not capitalized. If the first letter is
capitalized,
then everything is OK. I’ll appreciate any explanation for this
behavior.
In Ruby, everything starting with a capital letter is a constant.
Constants are visible globally anywhere in a program, hence you can
access it in your method.
The “def” keyword creates a new scope where you can’t access veriables
from the outside, which is why you can’t see them inside the method.