On the top level we can call `loop` method, but why not the same way
inside the method `show` ?
You are not invoking it inside #show, you are invoking it directly.
And you cannot call it with a receiver because it is defined private
in Kernel:
Kind regards
robert
I know `#loop` is a private method. And private method can't have an
explicit receiver. But you can see in my `#show` method, there is no
explicit call. Why then error ?
Yes. I know Fixnum has `#times` method. But `Kernel#loop` gives us
Enumerator, without block. I am trying to understand what is the actual
applicable area for that design(without block).
Why do we need `Kernel#loop` without block version ?
On the top level we can call `loop` method, but why not the same way
inside the method `show` ?
You are not invoking it inside #show, you are invoking it directly.
And you cannot call it with a receiver because it is defined private
in Kernel:
I know `#loop` is a private method. And private method can't have an
explicit receiver. But you can see in my `#show` method, there is no
explicit call. Why then error ?
There is. Read your first posting again.
Yes. I know Fixnum has `#times` method. But `Kernel#loop` gives us
Enumerator, without block. I am trying to understand what is the actual
applicable area for that design(without block).
There is not much. You can invoke #each on this (as well as #map
etc.) and it will run forever.
Why do we need `Kernel#loop` without block version ?
Probably because of consistency with other iteration methods.
Cheers
robert
···
On Thu, Jan 23, 2014 at 11:32 AM, Arup Rakshit <lists@ruby-forum.com> wrote: