From: "Darryl L. Pierce" Date: 2011-10-18T22:22:37+09:00 Subject: Re: Local and Global Variable On 10/18/2011 08:43 AM, Junayeed Ahnaf Nirjhor wrote: > I still don’t fully understand what is local and what is global variable. Can any of you please explain that to me? It's about the scope of the variable; i.e., what parts of your code can see those variables. Global variables are visible from any piece of code because their scope is global. They exist outside of any method, class or module. Globals start with $; i.e., $ARGV, $ANYBODY_CAN_SEE_ME and the like. And, the big one, global variables exist from the moment they are created until the application exits. Local variables only exist within a method or code block of some sort. So in the following code snippet: def farkle updated_count = $FARKLE_COUNT updated_count += 1 $FARKLE_COUNT = updated_count end $FARKLE_COUNT is a global variable, while updated_count is a local variable; i.e., when the method farkle() exits then updated_count will no longer exist. HTH. -- Darryl L. Pierce http://mcpierce.multiply.com/ "What do you care what people think, Mr. Feynman?"