On Jan 29, 8:52 pm, cmdjackr... / googlemail.com wrote:
> As I'm a beginner in Ruby, and just (re)started working on real code,
> instead of working through various tutorials, I'm asking myself: Is that
> the Ruby way?
>
> Snippet:
>
> unless File.exists?('data/finance.db') == true
>    setup = Database.new
>    setup.new_database
>    else
>      puts 'Database already exists!'
> end
>
> The code is tested and working as expected (Database is my own class,
> which creates the database in the first place), and I don't think it
> could be (much) shorter.

I'm a ruby-nuby as well, but for one thing I think you don't need that 
"== true" after the condition. If the method 'exists?' returns true, 
it is already taken as the value of the expression 'unless' needs to 
evaluate, so there's no need for the comparison.

Cheers,

Helder