Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

Ruby Classes

class Library
  attr_accessor :title, :author

  def readBook()
    puts "Reading #{self.title} by #{self.author}"
  end
end

book1 = Library.new()
book1.title = "Shreds of tenderness"
book1.author = "Dr Mwaniki"

book1.readBook()
puts book1.title
Source by www.tutorialspoint.com #
 
PREVIOUS NEXT
Tagged: #Ruby #Classes
ADD COMMENT
Topic
Name
2+3 =