Question : ruby constructor
Answered by : dhyani16
class className def initialize(parameter1,parameter2,parameter3) end
end
Source : | Last Update : Sun, 09 May 21
Question : Ruby constructors
Answered by : ben-kiboma
class Library attr_accessor :title, :author def initialize (title, author) @title = title @author = author end def readBook() puts "Reading #{self.title} by #{self.author}" end
end
book1 = Library.new("Shreds of tenderness","Dr Mwaniki")
puts book1.readBook()
puts book1.title
Source : | Last Update : Sat, 27 Aug 22