Forum: Ruby or = for a constant

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Bob Archer (Guest)
on 2008-12-04 22:12
(Received via mailing list)

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.

David A. Black (Guest)
on 2008-12-04 22:22
(Received via mailing list)
Hi --

On Fri, 5 Dec 2008, Bob Archer wrote:

> Is there a better way to do this?

WORKINGDIR = ENV['CCNetWorkingDirectory'] || "."

This topic is locked and can not be replied to.