Created
August 2, 2015 14:36
-
-
Save photomattmills/6a8a37a837de54c258d3 to your computer and use it in GitHub Desktop.
This file contains 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
#! /Users/matt/.rvm/rubies/ruby-2.2.1/bin/ruby | |
class Foo | |
attr_accessor :bar | |
def initialize | |
puts "initialized" | |
@bar = 5 | |
end | |
def bar_divider | |
@bar /= 5 | |
end | |
def broken_bar_divider | |
bar /= 5 | |
end | |
def other_divider | |
bar = 4/2 | |
end | |
def checker | |
puts bar | |
end | |
end | |
foo = Foo.new # => "initialized" | |
foo.checker # => 5 | |
p foo.bar_divider # => 1 | |
p foo.other_divider # doesn't actually assign bar | |
p foo.broken_bar_divider # undefined method '/' for nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment