Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the # (sharp, number, pound, hash) sign used for in Ruby?

Tags:

ruby

What are the various meanings of the Ruby sharp/number sign/pound/hash(#) symbol

How many contexts does the symbol # in Ruby have ?

I know that #` represents comment

# a comment 

or 'convert to the value':

i = 1 print "#{i}" # simple example 

However I also see some Ruby docs describe built-in methods like these:

Array#fill File::file? 

Why do they describe the same thing using 2 different symbols ? I am new in Ruby. Thanks

like image 589
JACK M Avatar asked Sep 03 '13 12:09

JACK M


People also ask

What is a the in grammar?

English has two articles: the and a/an. The is used to refer to specific or particular nouns; a/an is used to modify non-specific or non-particular nouns. We call the the definite article and a/an the indefinite article. the = definite article.

How old is the word the?

It was the language spoken by the Anglo-Saxon people under many dialects from about 500 to about 1100 when the Norman invasion began the transformation to Middle English. Depending on case and number, it has such meanings as: the; that; that one; who; which; that which; this; he; she, them, those, etc.

Where is the is used?

The is used to describe a specific noun, whereas a/an is used to describe a more general noun. For this reason, the is also referred to as a definite article, and a/an is referred to as an indefinite article. The definite article, the, is used before both singular and plural nouns when the noun is specific.

Why does English use the?

They tell if the noun is general or specific. When an article is specific, it is called a definite article. The word 'the' is a definite article. English speakers use 'the' when both the speaker and the listener know what is being referred to.


1 Answers

This is how instance method described:

Array#fill  

So you can:

a = Array.new(2)  => [nil, nil] a.fill(42)  => [42, 42] 

This is how class method described:

String::new  s = String.new('abc')  => "abc" 
like image 52
freemanoid Avatar answered Oct 15 '22 11:10

freemanoid