[squeak-dev] in Random class #index inst var is shadowed in 3
methods
Levente Uzonyi
leves at caesar.elte.hu
Thu May 12 08:23:58 UTC 2016
On Wed, 11 May 2016, PAUL DEBRUICKER wrote:
>
> Would that change the behavior of the methods?
>
>
> It doesn't seem to as the tests pass if you rename the index temp vars to idx.
>
>
> Why is that?
>
Because shadowing means that the shadowed variable will not be used. Since
those methods don't use the instance variable, it's perfectly fine to
reuse the name "index" instead of "idx" or "i" or whatever.
Levente
>
> Thanks
>
> Paul
>
>
>
More information about the Squeak-dev
mailing list
|