Skip to content

Commit 83d3a55

Browse files
author
Scott Carleton
committed
Merge branch 'class-and-instance-methods'
merging branch
2 parents 218e9a0 + d6c64d8 commit 83d3a55

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
GEM
22
remote: http://rubygems.org/
33
specs:
4-
RedCloth (4.2.7)
4+
RedCloth (4.2.9)
55
activesupport (3.0.7)
66
classifier (1.3.3)
77
fast-stemmer (>= 1.0.0)

chapters/classes_and_objects/class-methods-and-instance-methods.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ You want to create a class methods and instance methods.
1010
## Solution
1111

1212
### Class Method
13+
1314
{% highlight coffeescript %}
15+
1416
class Songs
1517
@_titles: 0 # Although it's directly accessible, the leading _ defines it by convention as private property.
1618

@@ -28,10 +30,13 @@ Songs.get_count()
2830
# => 1
2931

3032
song.get_count()
31-
# => TypeError: Object #<Songs> has no method 'get_count'
33+
# => TypeError: Object <Songs> has no method 'get_count'
34+
3235
{% endhighlight %}
3336

3437
### Instance Method
38+
{% highlight coffeescript %}
39+
3540
class Songs
3641
_titles: 0 # Although it's directly accessible, the leading _ defines it by convention as private property.
3742

@@ -47,6 +52,7 @@ song.get_count()
4752

4853
Songs.get_count()
4954
# => TypeError: Object function Songs(artist, title) ... has no method 'get_count'
55+
5056
{% endhighlight %}
5157

5258

0 commit comments

Comments
 (0)