Ruby
In Ruby, scope resolution can be specified using namespaces (such as classes or modules).
module Example Version = 1.0 class << self # We are accessing the Module's singleton class def hello(who = "World") "hello #{who}" end end end #/Example Example::hello # => "hello World" Example.hello "hacker" # => "hello hacker" Example::Version # => 1.0 Example.Version # NoMethodError # This illustrates the difference between the message (.) operator and the scope operator in Ruby (::) # We can use both ::hello and .hello, because hello is a part of Example's scope and because Example # responds to the message hello. # # We can't do the same with ::Version and .Version, because Version is within the scope of Example, but # Example can't respond to the message Version, since there is no method to respond with.Read more about this topic: Scope Resolution Operator
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 (18651939)
“Lay down, lay down the bigly bier,
Lat me the dead look on;
Wi cherry cheeks and ruby lips
She lay an smild 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 (17471810)
“Its quick silver bell beating, beating
And down the dark one ruby flare
Pulsing out red light like an artery,”
—Karl Shapiro (b. 1913)