File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
chapters/classes_and_objects Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change 1
1
GEM
2
2
remote: http://rubygems.org/
3
3
specs:
4
- RedCloth (4.2.7 )
4
+ RedCloth (4.2.9 )
5
5
activesupport (3.0.7 )
6
6
classifier (1.3.3 )
7
7
fast-stemmer (>= 1.0.0 )
Original file line number Diff line number Diff line change @@ -10,7 +10,9 @@ You want to create a class methods and instance methods.
10
10
## Solution
11
11
12
12
### Class Method
13
+
13
14
{% highlight coffeescript %}
15
+
14
16
class Songs
15
17
@_ titles: 0 # Although it's directly accessible, the leading _ defines it by convention as private property.
16
18
@@ -28,10 +30,13 @@ Songs.get_count()
28
30
# => 1
29
31
30
32
song.get_count()
31
- # => TypeError: Object #<Songs > has no method 'get_count'
33
+ # => TypeError: Object <Songs > has no method 'get_count'
34
+
32
35
{% endhighlight %}
33
36
34
37
### Instance Method
38
+ {% highlight coffeescript %}
39
+
35
40
class Songs
36
41
_ titles: 0 # Although it's directly accessible, the leading _ defines it by convention as private property.
37
42
@@ -47,6 +52,7 @@ song.get_count()
47
52
48
53
Songs.get_count()
49
54
# => TypeError: Object function Songs(artist, title) ... has no method 'get_count'
55
+
50
56
{% endhighlight %}
51
57
52
58
You can’t perform that action at this time.
0 commit comments