From: "Jesús Gabriel y Galán" Date: 2011-10-05T05:57:58+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 : >> 2011/10/4 Bartosz Dziewoñski : >>> 4. Block arguments and block-local variables >> >> Block arguments and block local variables are local to the block >> scope, not the method. > > If I understand the discussion correctly, the fact to what scope > exactly they are local doesn't matter; once it's defined, bareword > reference will resolve to the variable, not the method anymore. Of > course, after the block it will resolve to the method again. Well, I was referring to creating a local variable in the scope of the method, and trying to somewhat fight for my statement :-). But you are right, block arguments create local variables in its scope. > > irb(main):002:0> def x; 'foo'; end > => nil > irb(main):003:0> x > => "foo" > irb(main):004:0> 3.times{|x| p x} > 0 > 1 > 2 > => 3 > > >>> 5. Stabby Lambda variables >> >> What do you mean by this? > > Regular lambda: a = lambda{|x,y| x+y} - it cant have, for example, > default value for arguments. > > "Stabby" lambda, or "arrow" lambda: a = ->(x=5, y=6){x+y} = as you can > see, it's arguments work just like function's ones. Ah, ok. > > >>> 6. Rescue exception naming (rescue StandardError => err) >> >> Kind of assignment :-) > > Well, certainly not a regular one ;) Sure, in all your examples, someone, somewhere assigns a value to that variable, maybe it's under the hood, but there's an assignment. That's my argument (very shaky, I admit) to try to hold my statement. You are right there are other ways of having the parser understand that something is a local variable other than a pure assignment expression, although I still contend that method arguments, block arguments, lambda default values for arguments and exceptions are still assignments in a sense :). Jesus.