Afficher un message
Vieux 17/09/2007, 10h53   #4
Summercool Summercool
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Variable / Method Ambiguity

On Sep 17, 12:49 am, "David A. Black" <dbl...@rubypal.com> wrote:
>
> No, because there's no such variable in scope. The second time through
> the loop, there's no assignment to a, and the first variable a has
> gone out of scope. So the only thing that "a" could mean, outside of
> an assignment, is the method a.


wow... i thought the "a" variable is kind of like in C or Python:


for (i = 1; i <= 2; i++) {
int a;

if (i==2) {
...
} else {
...
}

}

so that the "a" exists all inside the for loop... maybe that's not
right.

now, we can view the variable "a" as existing in the else block but no
where else in the original Ruby code?

--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
 
Page generated in 0,04614 seconds with 9 queries