[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

catch throw ?

Paatsch, Bernd

3/9/2006 1:36:00 AM


Hello,

I just started using catch and throw. Therefore this question might be an
easy one.

I have multiple ruby files. In one of the files I like to throw and then in
the main function in a different file I like to catch the throw. Is this
possible or do throw/catch need to be in the same file?


Example:
fileOne.rb

def somefunct
....
throw :quit_script
....
end

fileTwo.rb
catch :quit_script
...
end

Thx,
Bernd
2 Answers

Logan Capaldo

3/9/2006 1:55:00 AM

0


On Mar 8, 2006, at 8:35 PM, Paatsch, Bernd wrote:

>
> Hello,
>
> I just started using catch and throw. Therefore this question might
> be an
> easy one.
>
> I have multiple ruby files. In one of the files I like to throw and
> then in
> the main function in a different file I like to catch the throw.
> Is this
> possible or do throw/catch need to be in the same file?
>
>
> Example:
> fileOne.rb
>
> def somefunct
> ....
> throw :quit_script
> ....
> end
>
> fileTwo.rb
> catch :quit_script
> ...
> end
>
> Thx,
> Bernd

They have to be in the same call chain.

so if fileTwo require's fileOne.rb and fileTwo's code looks like
catch :quit_script do
...
somefunct()
...
end

it will work




Ara.T.Howard

3/9/2006 3:06:00 AM

0