From: "Jesús Gabriel y Galán" Date: 2011-10-05T05:30:09+09:00 Subject: Re: Local vs method vs instance (was: Operator Overloading) 2011/10/4 Bartosz Dziewoński : > 2011/10/4 Jesús Gabriel y Galán : >> Only an assignment creates a local variable in the scope. >> > > This is actually only 1/7th true. There are as many as 7 ways to > introduce a new variable, out of which anybody would guess about 5 if > they though about it for a while ;), and 2 are quite obscure. > > These are: > > 1. Single- or multiple-assignment (including sub-assignment) anywhere > an expression is allowed > 2. A for loop's iterator variable(s) Kind of assignment :-) > 3. Formal arguments to a method Good one, I was thinking only in the body of the method, but you can also argue that someone does an assignment to them :-) > 4. Block arguments and block-local variables Block arguments and block local variables are local to the block scope, not the method. > 5. Stabby Lambda variables What do you mean by this? > 6. Rescue exception naming (rescue StandardError => err) Kind of assignment :-) > 7. Named Regexp captures in literal matches (/name: (?\w+)/ =~ > 'name: Mike' creates a local variable named "person" with value > "Mike") Didn't knew this one, thanks. Jesus.