Or = for a constant



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.



Hi –

On Fri, 5 Dec 2008, Bob Archer wrote:

Is there a better way to do this?

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