# Or = for a constant

**URL:** <https://www.ruby-forum.com/t/or-for-a-constant/154887>\
**Category:** Ruby\
**Created:** [December 4, 2008, 9:12pm UTC](https://www.ruby-forum.com/t/or-for-a-constant/154887 "2008-12-04T21:12:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bob\_Archer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c68b51/32.png) [@Bob\_Archer](https://www.ruby-forum.com/u/Bob_Archer)\
**Post date:** [December 4, 2008, 9:12pm UTC](https://www.ruby-forum.com/t/or-for-a-constant/154887/1 "2008-12-04T21:12:03Z")

</div>

Hello,

I want to set a constant to be the value from an env variable or if that  
is not there set it to the current directory.

So, I am doing this:

WORKINGDIR = ENV[‘CCNetWorkingDirectory’] ? ENV[‘CCNetWorkingDirectory’]  
: “.”

But it doesn’t seem very Ruby/DRY like.

Is there a better way to do this?

Sorry for the basic question… but 5 chapters into Why’s guide and I  
haven’t got to a solution yet.

BOb

---

<div class="post-metadata">

**Author:** ![Bob\_Archer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c68b51/32.png) [@Bob\_Archer](https://www.ruby-forum.com/u/Bob_Archer)\
**Post date:** [December 4, 2008, 9:22pm UTC](https://www.ruby-forum.com/t/or-for-a-constant/154887/2 "2008-12-04T21:22:36Z")

</div>

Hi –

On Fri, 5 Dec 2008, Bob Archer wrote:

> Is there a better way to do this?

WORKINGDIR = ENV[‘CCNetWorkingDirectory’] || “.”

David
