[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

What is Ruby equivalent of Python's ' if __name__ == "__main__" '

Kenneth McDonald

10/22/2008 3:32:00 PM

In Python, I can use the test indicated in the subject line to
determine if a file is being executed directly, as opposed to being
loaded indirectly as the result of the execution of another file. I
haven't been able to find the Ruby equivalent of this, and would be
most grateful is someone could point me in the right direction.

Thanks,
Ken McDonald


2 Answers

Stephen Duncan Jr

10/22/2008 3:41:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

On Wed, Oct 22, 2008 at 11:32 AM, Kenneth McDonald <
kenneth.m.mcdonald@sbcglobal.net> wrote:

> In Python, I can use the test indicated in the subject line to determine if
> a file is being executed directly, as opposed to being loaded indirectly as
> the result of the execution of another file. I haven't been able to find the
> Ruby equivalent of this, and would be most grateful is someone could point
> me in the right direction.
>
> Thanks,
> Ken McDonald
>

if $PROGRAM_NAME == __FILE__

--
Stephen Duncan Jr
www.stephenduncanjr.com

Jesús Gabriel y Galán

10/22/2008 3:45:00 PM

0

On Wed, Oct 22, 2008 at 5:32 PM, Kenneth McDonald
<kenneth.m.mcdonald@sbcglobal.net> wrote:
> In Python, I can use the test indicated in the subject line to determine if
> a file is being executed directly, as opposed to being loaded indirectly as
> the result of the execution of another file. I haven't been able to find the
> Ruby equivalent of this, and would be most grateful is someone could point
> me in the right direction.

if __FILE__ == $0

end


Jesus.