Skip to content

Commit 57c445a

Browse files
committed
Showed how to access from an instance method
1 parent 38dc427 commit 57c445a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: chapters/classes_and_objects/class-variables.md

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ You want to create a class variable.
1313
class Zoo
1414
@MAX_ANIMALS: 50
1515
MAX_ZOOKEEPERS: 3
16+
17+
helpfulInfo: =>
18+
"Zoos may contain a maximum of #{@constructor.MAX_ANIMALS} animals"
1619

1720
Zoo.MAX_ANIMALS
1821
# => 50
@@ -23,6 +26,8 @@ Zoo.MAX_ZOOKEEPERS
2326
zoo = new Zoo
2427
zoo.MAX_ZOOKEEPERS
2528
# => 3
29+
zoo.helpfulInfo()
30+
# => "Zoos may contain a maximum of 50 animals"
2631
{% endhighlight %}
2732

2833
## Discussion

0 commit comments

Comments
 (0)