Forum: Ruby or = for a constant

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bob Archer (Guest)
on 2008-12-04 22:12
(Received via mailing list)
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
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'] || "."


David
This topic is locked and can not be replied to.