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:
“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 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)
“A man in the house is worth two in the street.”
—Mae West, U.S. actor, screenwriter, and Leo McCarey. Ruby Carter (Mae West)