# Private(true) || private :make\_time, what does it do? why?

**URL:** <https://www.ruby-forum.com/t/private-true-private-make-time-what-does-it-do-why/132967>\
**Category:** Ruby\
**Created:** [March 26, 2008, 9:09am UTC](https://www.ruby-forum.com/t/private-true-private-make-time-what-does-it-do-why/132967 "2008-03-26T09:09:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a6a055/32.png) [@Rie](https://www.ruby-forum.com/u/Rie)\
**Post date:** [March 26, 2008, 9:09am UTC](https://www.ruby-forum.com/t/private-true-private-make-time-what-does-it-do-why/132967/1 "2008-03-26T09:09:14Z")

</div>

i found that rake source has got this strange one line of code

private(true)

or something, true could be another code (I don’t remember that rake  
source code by heart). I’m not sure I can explain it clearly. Now I  
just saw it again in time.rb file inside lib in ruby19 source code,  
the code is like this

private :make\_time

could anyone explain to me why this private takes an argument and what  
it does?

–  
blog: [http://tinyurl.com/2bjgvn](http://tinyurl.com/2bjgvn),  
ruby: [Tentang Ruby](http://www.ruby-lang.org/id/about)

I always thought Smalltalk would beat Java, I just didn’t know it  
would be called ‘Ruby’ when it did. – Kent Beck.

---

<div class="post-metadata">

**Author:** ![Rie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a6a055/32.png) [@Rie](https://www.ruby-forum.com/u/Rie)\
**Post date:** [March 26, 2008, 9:16am UTC](https://www.ruby-forum.com/t/private-true-private-make-time-what-does-it-do-why/132967/2 "2008-03-26T09:16:56Z")

</div>

From: Rie! [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]

# could anyone explain to me why this private takes an argument

# and what it does?

qri is your friend

## botp@pc4all:~$ qri private --------------------------------------------------------- Module#private private =\> self private(symbol, …) =\> self

```
 With no arguments, sets the default visibility for subsequently
 defined methods to private. With arguments, sets the named methods
 to have private visibility.

    module Mod
      def a() end
      def b() end
      private
      def c() end
      private :a
    end
    Mod.private_instance_methods #=> ["a", "c"]

```

kind regards -botp

---

<div class="post-metadata">

**Author:** ![Rie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a6a055/32.png) [@Rie](https://www.ruby-forum.com/u/Rie)\
**Post date:** [March 26, 2008, 12:40pm UTC](https://www.ruby-forum.com/t/private-true-private-make-time-what-does-it-do-why/132967/3 "2008-03-26T12:40:59Z")

</div>

On 26/03/2008, Peña, Botp [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> module Mod
> def a() end
> def b() end
> private
> def c() end
> private :a
> end
> Mod.private_instance_methods #=> ["a", "c"]
> 
> ```

if it’s only about a method then it’s trivial, what I meant was  
something like this.

private(\*somethingsomething)

anyone can explain it to me more clear?

m:lib arie$ rak “private(” rake.rb  
1091|private(\*FileUtils.instance\_methods(false))  
1092|private(\*RakeFileUtils.instance\_methods(false))

oh wait, sorry for the noise, I know the answer! so private also  
accepts an array of string values which are method names. Thanks for  
the clue 🙂

> kind regards -botp

–  
blog: [http://tinyurl.com/2bjgvn](http://tinyurl.com/2bjgvn),  
ruby: [Tentang Ruby](http://www.ruby-lang.org/id/about)

I always thought Smalltalk would beat Java, I just didn’t know it  
would be called ‘Ruby’ when it did. – Kent Beck.

---

<div class="post-metadata">

**Author:** ![Rie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a6a055/32.png) [@Rie](https://www.ruby-forum.com/u/Rie)\
**Post date:** [March 26, 2008, 1:40pm UTC](https://www.ruby-forum.com/t/private-true-private-make-time-what-does-it-do-why/132967/4 "2008-03-26T13:40:55Z")

</div>

> On 26/03/2008, Peña, Botp [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:  
> m:lib arie$ rak “private(” rake.rb  
> 1091|private(\*FileUtils.instance\_methods(false))  
> 1092|private(\*RakeFileUtils.instance\_methods(false))
> 
> oh wait, sorry for the noise, I know the answer! so private also  
> accepts an array of string values which are method names. Thanks for  
> the clue 🙂

Slightly more precisely (and very pedantically), private _isn’t_  
accepting  
an array in this case. The \* is there to expand an array (which it  
doesn’t  
want) in to seperate arguments (which it likes).

Cheers,  
B
