Skip to content

Instantly share code, notes, and snippets.

@mrorii
Created March 27, 2010 11:27
Show Gist options
  • Select an option

  • Save mrorii/345956 to your computer and use it in GitHub Desktop.

Select an option

Save mrorii/345956 to your computer and use it in GitHub Desktop.
class Hoge
def initialize(state, foo)
@state = state
@foo = foo
end
def state=(new_state)
@state = new_state
end
def print
puts "@state is #{@state} and @foo is #{@foo}"
end
end
h = Hoge.new("aho", 1)
h.print #=> @state is aho and @foo is 1
h.state = "baka" # 8 行目の state= を呼ぶ
h.print #=> @state is baka and @foo is 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment