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.
Ca1b1806b7a8ec91fd3ea70efbc2f8aa?d=identicon&s=25 Bob Archer (Guest)
on 2008-12-04 21: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
F53b05cdbdf561cfe141f69b421244f3?d=identicon&s=25 David A. Black (Guest)
on 2008-12-04 21: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.