On 30.01.2007 01:37, cmdjackryan / googlemail.com wrote:
> Tamreen Khan wrote:
>> Also, I'd put the 'else' on the same level of indentation as the 
>> unless. As
>> Helder wrote, you don't need the == true bit, Ruby's all about natural 
>> code.
>>
> 
> Yeah, I did the former already (I like it better that way). And omitting 
> the ==true part makes the code more readable.

It actually also makes to code more correct.  In Ruby only nil and false 
are treated as false and everything else is true.  So "if expr" and "if 
expr == true" are likely to behave very differently.

With regard to your original piece of code, since you are using both 
branches (true and false) I would prefer to use "if" as it makes things 
a bit more readable IMHO:

if File.exists? 'data/finance.db'
   puts 'Database already exists!'
else
   setup = Database.new
   setup.new_database
end

Kind regards

	robert