On Tuesday 25 November 2003 01:14, T. Onoma wrote:
> "Wait a minute."  Why isn't  a  available in the scope of this method
> definition? What's the reasoning behind preventing that? Ruby does
> assign a, so its there. What scope is it assigning it to? Is it only useful
> at the time of module/class definition? That seems limited, how often does
> such a variable get used? I don't think I ever have.

I know what you mean.  I tend to want to scope things up when using irb; that 
bites me all the time.  However, @ resolves ambiguity:

If we don't have @, then:

class Foo
	a = "blah"
	def bar
		a = 1 + 1
	end
end

What would "a" be?  In this trivial case, it may not be a problem.  But in a 
large class, with a lot of methods, the odds of overriding some instance 
variable has a great potential to introduce bugs.  Also, how would you 
declare an instance variable in a method?

def Foo
	def bar
		a = "Foo"  # I want "a" to be an instance variable
		b = "Bar"  # I don't want "b" to be an instance variable
	end
end

--- SER