List Info

Thread: Re: Understanding the output of Kernel#caller




Re: Understanding the output of Kernel#caller
country flaguser name
United States
2008-07-02 17:59:01
Yehuda Katz wrote:
> This manifests itself in rescues as well:
> 
> def caller_in_eval
>   eval("raise 'w00t'")
> end
> 
> def method_with_block
>   begin
>     yield
>   rescue
>     p "method_with_block"
>   end
> end
> 
> method_with_block do
>   begin
>     caller_in_eval
>   rescue
>     p "calling m_w_b"
>   end
> end
> 
> You would expect to see "method_with_block"
but instead get "calling m_w_b"

Why would you expect that? The "calling m_w_b"
rescue is the first one 
encountered after the exception is raised.

- Cahrlie


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )