Advertisement
Hiteshw11

Classes & Objects in Ruby

Sep 28th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.22 KB | None | 0 0
  1. class Person
  2.     attr_accessor :Name, :Age, :Course #attributes of a class
  3. end
  4.  
  5. Per=Person.new() #creating new object
  6. Per.Name="John"
  7. Per.Age="75"
  8. Per.Course="Ruby Programming"
  9.  
  10. puts Per.Name
  11. puts Per.Age
  12. puts Per.Course
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement