Skip to content

Instantly share code, notes, and snippets.

@walski
Created June 28, 2013 10:26
Show Gist options
  • Save walski/5883801 to your computer and use it in GitHub Desktop.
Save walski/5883801 to your computer and use it in GitHub Desktop.
Why?
class WTF
attr_reader :color
def initialize
@color = 'red'
end
def color_with_self
color = self.color
color
end
def color_without_self
color = color
color
end
end
require "test/unit"
include Test::Unit::Assertions
color_with_self = WTF.new.color_with_self
assert(color_with_self == "red", "#{color_with_self.inspect} should be 'red'")
color_without_self = WTF.new.color_without_self
assert(color_without_self == "red", "#{color_without_self.inspect} should be 'red'")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment