Skip to content

Instantly share code, notes, and snippets.

@justincampbell
Created May 21, 2012 19:55
Show Gist options
  • Save justincampbell/2764277 to your computer and use it in GitHub Desktop.
Save justincampbell/2764277 to your computer and use it in GitHub Desktop.
attr_accessor test for RubyMotion 1.5
(main)> class AttrTest
(main)> attr_accessor :accessor
(main)> attr_reader :reader
(main)> attr_writer :writer
(main)>
(main)> def initialize(accessor, reader, writer)
(main)> @accessor = accessor
(main)> @reader = reader
(main)> @writer = writer
(main)> end
(main)> end
=> nil
(main)> test = AttrTest.new 1, 2, 3
=> #<AttrTest:0xa3ee5f0 @accessor=1 @reader=2 @writer=3>
(main)> test.reader
=> 2
(main)> test.accessor
=> 1
(main)> test.writer
=> #<NoMethodError: undefined method `writer' for #<AttrTest:0xa3ee5f0 ...>>
(main)> test.writer = 5
generate KVO name for @writer
=> 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment