Skip to content

Instantly share code, notes, and snippets.

@ryanlecompte
Created April 4, 2011 16:32
Show Gist options
  • Save ryanlecompte/901925 to your computer and use it in GitHub Desktop.
Save ryanlecompte/901925 to your computer and use it in GitHub Desktop.
>> module M
>> x = 100
>> define_method(:x=) {|v| x = v }
>> define_method(:x) { x }
>> end
=> #<Proc:0x0000010102dfd0@(irb):4 (lambda)>
>> class A
>> include M
>> end
=> A
>> class B
>> include M
>> end
=> B
>> a = A.new
=> #<A:0x0000010103c030>
>> b = B.new
=> #<B:0x00000101039bf0>
>> a.x
=> 100
>> b.x
=> 100
>> a.x = 5
=> 5
>> b.x
=> 5
>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment