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:

    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)

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

    Lay down, lay down the bigly bier,
    Lat me the dead look on;
    Wi’ cherry cheeks and ruby lips
    She lay an’ smil’d on him.

    O ae sheave o’ your bread, true-love,
    An’ ae glass o’ your wine,
    For I hae fasted for your sake
    These fully day [is] nine.
    Anna Gordon Brown (1747–1810)