On 4/10/06, Austin Z. [email protected] wrote:
end
end
[different third class deleted]
Am I correct in believing that they are equivalent? If not, how do they
differ?
They are not equivalent. The first two are the same, but the third
will be accessing @bar, not @@bar. (Try it in IRB and you’ll see.)
Interestingly though, the the sexps representing the AST for the first
two
classes are pretty different looking:
[[:class,
:Example,
:Object,
[:defn,
:example,
[:scope,
[:block,
[:args],
[:defs, [:self], :bar, [:scope, [:block, [:args], [:cvar,
:@@bar]]]],
[:defs,
[:self],
:bar=,
[:scope, [:block, [:args, :val], [:cvasgn, :@@bar, [:lvar,
:val]]]]]]]]]
vs.
[[:class,
:Example,
:Object,
[:defn,
:example,
[:scope,
[:block,
[:args],
[:sclass,
[:self],
[:scope,
[:block,
[:defn, :bar, [:scope, [:block, [:args], [:cvar, :@@bar]]]],
[:defn,
:bar=,
[:scope,
[:block, [:args, :val], [:cvasgn, :@@bar, [:lvar,
:val]]]]]]]]]]]]]