Constructor (object-oriented Programming) - Ruby

Ruby

In Ruby, constructors are created by defining a method called initialize. This method is executed everytime a new instance is created.

class ExampleClass def initialize return "Hello there" end end exampleInstance = ExampleClass.new puts exampleInstance # => "Hello there"

Read more about this topic:  Constructor (object-oriented Programming)

Famous quotes containing the word ruby:

    “It is better to be looked over than overlooked.”
    —Mae West, U.S. actor, screenwriter, and Leo McCarey. Ruby Carter (Mae West)

    “Thy great leaves enfold
    The ancient beards, the helms of ruby and gold
    Of the crowned Magi; and the king whose eyes
    Saw the Pierced Hands and Rood of elder rise
    In Druid vapour and make the torches dim....”
    —William Butler Yeats (1865–1939)

    “Its quick silver bell beating, beating
    And down the dark one ruby flare
    Pulsing out red light like an artery,”
    —Karl Shapiro (b. 1913)