Skip to content

Instantly share code, notes, and snippets.

@luckydev
Created December 24, 2012 09:02
Show Gist options
  • Save luckydev/4368465 to your computer and use it in GitHub Desktop.
Save luckydev/4368465 to your computer and use it in GitHub Desktop.
What I <3 in Ruby. reOpen classes anytime. Do any shit with them, they will digest :)
irb(main):007:0> class Person
irb(main):008:1> attr_accessor :name,:email
irb(main):009:1> end
=> nil
irb(main):010:0> p = Person.new
=> #<Person:0x007fa40a038378>
irb(main):011:0> p.name
=> nil
irb(main):012:0> p.email
=> nil
irb(main):013:0> p.name= "Marco"
=> "Marco"
irb(main):014:0> p.email= "[email protected]"
=> "[email protected]"
irb(main):015:0> p
=> #<Person:0x007fa40a038378 @name="Marco", @email="[email protected]">
irb(main):016:0> class Person
irb(main):017:1> attr_accessor :last_name
irb(main):018:1> end
=> nil
irb(main):019:0> p
=> #<Person:0x007fa40a038378 @name="Marco", @email="[email protected]">
irb(main):020:0> p.last_name
=> nil
irb(main):021:0> p.last_name = "Ament"
=> "Ament"
irb(main):022:0> p
=> #<Person:0x007fa40a038378 @name="Marco", @email="[email protected]", @last_name="Ament">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment