Hello --

On Fri, 16 Aug 2002, MikkelFJ wrote:

> @a = 2
>
> def double_a
>   @a + @a
> end
>
> double_a # -> 4
>
> Variables starting with @ are visible both inside and outside of functions.

The only place that happens, I think, is at the "top level" of
execution.  Otherwise it's like this:

  class Thing
    @a = 1
    puts "Class scope: @a is >#{@a}<"

    def show
      puts "Instance scope: @a is >#{@a}<"
    end
  end

  Thing.new.show

  =>
    Class scope: @a is >1<
    Instance scope: @a is ><         # this @a is nil


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav