Last active
December 16, 2015 17:50
-
-
Save octosteve/5473595 to your computer and use it in GitHub Desktop.
This makes me angry... but it makes sense.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Subteddit | |
| def self.add_story(story) | |
| @story ||= [] | |
| @story << story | |
| end | |
| def add_story(story) | |
| @story ||= [] | |
| @story << story | |
| end | |
| def self.stories | |
| puts @story | |
| end | |
| def stories | |
| puts @story | |
| end | |
| end | |
| puts "Class Story" | |
| 3.times do | |
| Subteddit.add_story("foo") | |
| end | |
| puts "As a class method" | |
| Subteddit.stories | |
| 3.times do | |
| puts "For the instance" | |
| st = Subteddit.new | |
| st.add_story("bar") | |
| st.stories | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment