# $0 global variable

**URL:** <https://www.ruby-forum.com/t/0-global-variable/124460>\
**Category:** IronRuby\
**Created:** [December 28, 2007, 10:32pm UTC](https://www.ruby-forum.com/t/0-global-variable/124460 "2007-12-28T22:32:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![editkid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/977dab/32.png) [@editkid](https://www.ruby-forum.com/u/editkid)\
**Post date:** [December 28, 2007, 10:32pm UTC](https://www.ruby-forum.com/t/0-global-variable/124460/1 "2007-12-28T22:32:03Z")

</div>

I would really like to be able to do this:

if **FILE** == $0

require File.dirname( **FILE** ) + ‘/…/…/Util/simple\_test.rb’

end

But, since $0 currently always returns nil, I can’t.

Any chance you could squeeze it into the next SVN revision?

Cheers,

Pete

---

<div class="post-metadata">

**Author:** ![editkid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/977dab/32.png) [@editkid](https://www.ruby-forum.com/u/editkid)\
**Post date:** [January 2, 2008, 11:31pm UTC](https://www.ruby-forum.com/t/0-global-variable/124460/2 "2008-01-02T23:31:43Z")

</div>

Peter Bacon D.:

> I would really like to be able to do this:
> 
> if **FILE** == $0  
> require File.dirname( **FILE** ) + ‘/…/…/Util/simple\_test.rb’  
> end
> 
> But, since $0 currently always returns nil, I can’t.
> 
> Any chance you could squeeze it into the next SVN revision?

John L. has ARGV working–presumably it’s not too hard to make $0 work  
too.

- John

---

<div class="post-metadata">

**Author:** ![editkid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/977dab/32.png) [@editkid](https://www.ruby-forum.com/u/editkid)\
**Post date:** [January 2, 2008, 11:53pm UTC](https://www.ruby-forum.com/t/0-global-variable/124460/3 "2008-01-02T23:53:59Z")

</div>

Thanks Johns. I have worked around it so it is not so important now.  
Nearly got the rest of the number stuff done. Look out for a big new  
year  
patch soon.  
Pete
