On Apr 24, 2012, at 9:51 AM, Rick Waldron wrote:
> On Tue, Apr 24, 2012 at 12:33 PM, Tab Atkins Jr. <[email protected]> wrote:
> On Mon, Apr 23, 2012 at 3:36 PM, David Herman <[email protected]> wrote:
> >
> > box = {
> > _value: 0,
> > get: () -> this._value,
> > set(v) { this._value = v }
> > }
>
> I don't understand this example. What is "set(v) {...}"? It's not a
> setter, because it's not associated with a property name. Assuming
> you meant "set value(v) {...}", why not just use an ordinary getter as
> well?
>
> When I read this, I assumed it was a reference to this:
> http://wiki.ecmascript.org/doku.php?id=harmony:object_literals#object_literal_property_shorthands
Right. Thanks for providing the reference.
> Which would produce a method named "set" on "box"
>
> > box.set(42)
> > box.get()
>
> 42
>
> The example is easily confused.
Yeah, my bad. I was trying to demonstrate several syntaxes but shouldn't've
picked an example with a method named "set". To clarify the example:
box = {
_value: 0,
unbox: () -> this._value,
setbox(v) { this._value = v }
}
Dave
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss