or = for a constant

B

Bob Archer

Hello,

=20

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.

=20

So, I am doing this:

=20

WORKINGDIR =3D ENV['CCNetWorkingDirectory'] ? =
ENV['CCNetWorkingDirectory']
: "."

=20

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

=20

Is there a better way to do this?

=20

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

=20

BOb

=20
 
D

David A. Black

Hi --

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?

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


David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top