Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

ruby constructor

class className

   def initialize(parameter1,parameter2,parameter3)

   end

end
Comment

Ruby constructors

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
Comment

PREVIOUS NEXT
Code Example
Ruby :: ruby if else 
Ruby :: ruby rails migrate check status 
Ruby :: rails array pop first n elements 
Ruby :: ruby array loop 
Ruby :: ruby name parameters 
Ruby :: install ruby on rails ubuntu 18.04 
Ruby :: gem friendly_id with multiple column s 
Ruby :: how to add variable inside string ruby 
Ruby :: ||= ruby 
Ruby :: ruby do something x times 
Ruby :: ruby nth element of array 
Ruby :: why are getters and setters important ruby 
Ruby :: ruby find by multiple columns 
Ruby :: rails select arbitrary n element from array 
Ruby :: self join relationship rails 
Ruby :: Ruby deep clone with Marshal 
Ruby :: capybara click with offset 
Ruby :: save rails c output 
Ruby :: ruby if statement 
R :: R, how to count missing values in a column 
R :: size of ticks labels in r ggplot 
R :: r convert list to comma separated string 
R :: how to title plot in r 
R :: superscript in r 
R :: remove row from matrix r 
R :: repeat each value in a vector in r 
R :: How to use par() in R 
R :: finding index of element in r 
R :: load multiple packages in r 
R :: R tutorial 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =