[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Why "Kernel.puts" and not "Kernel.put"?

shadytrees

4/7/2006 10:57:00 PM

It puzzles me since other methods such as "Array.fill" or
"String.slice" all use the imperative mood, the one without an "s"
attached to a verb, but "Kernel.puts" uses third-person singluar, the
one with an "s." Is there a reason behind the different naming?

4 Answers

Daniel Schierbeck

4/7/2006 11:08:00 PM

0

shadytrees@gmail.com wrote:
> It puzzles me since other methods such as "Array.fill" or
> "String.slice" all use the imperative mood, the one without an "s"
> attached to a verb, but "Kernel.puts" uses third-person singluar, the
> one with an "s." Is there a reason behind the different naming?
`puts' and `gets' are not words used solely by Ruby. In fact, I think
practically all programming languages use them.

I've always thought they were abbreviations of `put string' and `get
string', respectively.


Daniel

Tim Hunter

4/7/2006 11:31:00 PM

0

Daniel Schierbeck wrote:
> shadytrees@gmail.com wrote:
>
>> It puzzles me since other methods such as "Array.fill" or
>> "String.slice" all use the imperative mood, the one without an "s"
>> attached to a verb, but "Kernel.puts" uses third-person singluar, the
>> one with an "s." Is there a reason behind the different naming?
>
> `puts' and `gets' are not words used solely by Ruby. In fact, I think
> practically all programming languages use them.
>
> I've always thought they were abbreviations of `put string' and `get
> string', respectively.
>
>
> Daniel

I'm reasonably certain the method is named after the "puts" ("put
string") function in the standard C library. There are many methods in
Ruby that are named the same as their corresponding C or Unix function:
system, raise, fork, printf and sprintf, putc, exit, etc.

paul.denlinger@gmail.com

4/8/2006 1:26:00 AM

0

"puts" stands for "put string". For a detailed explanation, please go
to http://pine.fm/LearnToProgram/?...

Paul Denlinger

shadytrees

4/8/2006 1:42:00 PM

0

Awesome. Thanks.