Advertisement
Hiteshw11

Classes & Objects Using Initialize Method

Sep 28th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.29 KB | None | 0 0
  1. class Person
  2. attr_accessor :Name, :Age, :Course
  3.     def initialize(name,age,course)
  4.         @Name=name
  5.         @Age=age
  6.         @Course=course
  7.     end
  8. end
  9.  
  10. Per=Person.new("John","35","Ruby Programming")
  11. puts Per.Name
  12. puts Per.Age
  13. puts Per.Course
  14.  
  15. =begin
  16. OUTPUT:-
  17.  
  18. John
  19. 35
  20. Ruby Programming
  21.  
  22. =end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement