Skip to content

Instantly share code, notes, and snippets.

@octosteve
Last active December 16, 2015 17:50
Show Gist options
  • Select an option

  • Save octosteve/5473595 to your computer and use it in GitHub Desktop.

Select an option

Save octosteve/5473595 to your computer and use it in GitHub Desktop.
This makes me angry... but it makes sense.
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