Skip to content

Added Instance variables to cookbook #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 18, 2014

Conversation

pbihler
Copy link
Contributor

@pbihler pbihler commented Sep 17, 2014

No description provided.

pbihler added 2 commits September 17, 2014 10:21
Added section about instance variables (properties), including warning about accidentially adding it to the class prototype
{% endhighlight %}

#### WARNING!
*Do not add the variable accidently to the prototype, by defining it outside the constructor* (Even if mentioned [elsewhere](http://arcturo.github.io/library/coffeescript/03_classes.html#content), this does not work as intended, due to the underlying JavaScript prototype concept).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to mention that it only works for primitive properties (= number, string, boolean, null or undefined)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to mention that it works only for primitive properties (=
|number|, |string|, |boolean|, |null| or |undefined|)?
I wouldn't emphazise on that, since it is only a very special case, and
the constructor-pattern is failsafe.


Reply to this email directly or view it on GitHub
https://github.com/coffeescript-cookbook/coffeescript-cookbook.github.com/pull/121/files#r17658658.

GPG/PGP Key-ID: 0xE18D34F6,

Qeevee GmbH
Firmensitz: Dahlmannstr. 2, B-IT Center, 53113 Bonn, Germany
Registergericht: Bonn HRB 17466
Geschäftsführer: Holger Mügge, Mark von Zeschau
Umsatzsteuer-Identifikationsnummer: DE267457882

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 - agreed :)

@wilzbach
Copy link

This is a very common problem for newbies to CoffeeScript.
Please merge this as #110 was also about explaining common pitfalls with instance variables :)

@pbihler pbihler closed this Sep 18, 2014
@pbihler pbihler reopened this Sep 18, 2014
peterhellberg added a commit that referenced this pull request Sep 18, 2014
Added Instance variables to cookbook
@peterhellberg peterhellberg merged commit b0861b2 into coffeescript-cookbook:master Sep 18, 2014
@peterhellberg
Copy link
Member

Thank you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants