Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Showed how to access class variables from an instance method #77

Merged
merged 1 commit into from

2 participants

Iain Beeston Peter Hellberg
Iain Beeston
Collaborator

Not sure if this is the preferred way of doing this, but it's the only way I know of

Peter Hellberg

I’ll merge this pull request, but you might want to move it to the “Instance Method” section instead. Or write a description about why there is an instance method in the Class Variables example.

I’ll also add you to the team :)

Peter Hellberg peterhellberg merged commit 653016f into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 9, 2013
  1. Iain Beeston
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 0 deletions.
  1. +5 −0 chapters/classes_and_objects/class-variables.md
5 chapters/classes_and_objects/class-variables.md
View
@@ -13,6 +13,9 @@ You want to create a class variable.
class Zoo
@MAX_ANIMALS: 50
MAX_ZOOKEEPERS: 3
+
+ helpfulInfo: =>
+ "Zoos may contain a maximum of #{@constructor.MAX_ANIMALS} animals"
Zoo.MAX_ANIMALS
# => 50
@@ -23,6 +26,8 @@ Zoo.MAX_ZOOKEEPERS
zoo = new Zoo
zoo.MAX_ZOOKEEPERS
# => 3
+zoo.helpfulInfo()
+# => "Zoos may contain a maximum of 50 animals"
{% endhighlight %}
## Discussion
Something went wrong with that request. Please try again.