On Mon, Mar 10, 2014 at 12:41 PM, Arup Rakshit <lists / ruby-forum.com> wrote:
> Xavier Noria wrote in post #1139365:

>> , you will get
>> unexpected behavior if you run it again.
>
> No, you can call `initialize`, but _implicitly_. See below.
>
> class Person
>   def initialize(name)
>     "I am calling from #{name}"
>   end
>   def call_initialize
>     initialize(__method__)
>   end
> end
>
> pr = Person.new('foo')
> puts pr.call_initialize
> # I am calling from call_initialize

Even this invocation will fail because of insufficient number of
arguments. Btw, you do not need to define another method, you can
simply use #send.

> The fact to note here is - A method you are creating in the **public**
> scope, became **provate** by the magic of Ruby's internal. That is
> misleading somehow.

I beg to differ: you do not invoke #initialize explicitly anyway. So
this exception helps us avoid errors.

> This is an **Exception** .

Yes, as is mentioned in the book Xavier recommended earlier.

Cheers

robert


-- 
[guy, jim].each {|him| remember.him do |as, often| as.you_can - without end}
http://blog.rubybestpractices.com/