On Wed, Jun 1, 2011 at 6:01 PM, Chad Perrin <code / apotheon.net> wrote:
> As I understand things:
>
> * Variables whose names have no leading sigil have local scope.
>
> * Instance variables are local scope for the particular instance of a
> =A0class within which they "live".
>
> * A Ruby program's "global" scope is actually the scope of an instance of
> =A0Object (or, under certain circumstances, maybe it could be an instance
> =A0of something further down the class inheritance hierarchy . . . ?).
>
> As such, it seems that within your program's "global" scope (not truly
> global, but close enough for government work in most cases), the
> effective difference between variables named foo and @foo is nothing but
> one character. =A0Is there some technical difference that might have an
> effect on the "behavior"[0] of the code I write, as long as neither of
> them is being exported to some other running code or enclosed in a more
> restricted scope within my program?
>
> ## NOTES
>
> [0]: =A0Someone actually flamed me for referring to the "behavior" of som=
e
> code, once upon a time -- thus the scare quotes around behavior in this
> case.
>
> --
> Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]
>

Well, @vars in main are visible to methods defined in main. For example:

@foo =3D 1
foo =3D 1

def bar
  @foo =3D 10
end

def baz
  foo =3D 10
end

bar
baz

p @foo   # =3D> 10
p foo    # =3D> 2

Is that the kind of difference you're interested in?

Regards,
Sean