__FILE__ == $0 refactored in Ruby? 
Author Message
 __FILE__ == $0 refactored in Ruby?

I see __FILE__ == $0 frequently. Is there a more readable form of this
already in Ruby? -- something like:

  def fileExecutedIsThisFile
    __FILE__ == $0
  end

Chris Morris



Wed, 21 Apr 2004 03:38:33 GMT  
 __FILE__ == $0 refactored in Ruby?
Hello --

Quote:

> I see __FILE__ == $0 frequently. Is there a more readable form of this
> already in Ruby? -- something like:

>   def fileExecutedIsThisFile
>     __FILE__ == $0
>   end

I don't think I know of a more readable version.  Did you want to
suggest one?  :-)

(I know, I know.)

Have a look at the thread starting at:

  Subject: [ruby-talk:21504] Replacement for __FILE__ == $0

for some earlier discussion of this.

David

--
David Alan Black


Web:  http://pirate.shu.edu/~blackdav



Wed, 21 Apr 2004 04:02:50 GMT  
 __FILE__ == $0 refactored in Ruby?

Quote:
>   Subject: [ruby-talk:21504] Replacement for __FILE__ == $0

> for some earlier discussion of this.

Although it didn't go too far.

We already have BEGIN {} and END {}

How about

   IF_RUN do
      ...
      ...
   end

Dave



Wed, 21 Apr 2004 04:17:39 GMT  
 __FILE__ == $0 refactored in Ruby?
Hello --

Quote:


> >   Subject: [ruby-talk:21504] Replacement for __FILE__ == $0

> > for some earlier discussion of this.

> Although it didn't go too far.

> We already have BEGIN {} and END {}

> How about

>    IF_RUN do
>       ...
>       ...
>    end

Or maybe broken out into:

  if __RUN__ do
    ...
  end

(just to harmonize with the surrounding syntax)

David

--
David Alan Black


Web:  http://pirate.shu.edu/~blackdav



Wed, 21 Apr 2004 04:26:16 GMT  
 __FILE__ == $0 refactored in Ruby?
This is excellent!
Quote:
> -----Original Message-----

> Sent: Friday, November 02, 2001 3:26 PM
> To: ruby-talk ML
> Subject: [ruby-talk:24198] Re: __FILE__ == $0 refactored in Ruby?

> [. . .]

>   if __RUN__ do
>     ...
>   end

> (just to harmonize with the surrounding syntax)



Wed, 21 Apr 2004 04:29:55 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. ruby 1.6.5, irb $0

2. $0 == __FILE__ idiom for Unix only?

3. Replacement for __FILE__ == $0

4. Appending to $0 or $_

5. variable as search-pattern: if ($0 ~ myVar)

6. executable awk scripts and shell var $(basename $0)

7. Newbie Help required: Deleting double entries in a line ($0)

8. !x[$0]++

9. mechanism of application ($0 or the line)

10. $0 == false ??

11. program name -> perl's $0

12. Maximum size of $0

 

 
Powered by phpBB® Forum Software