The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
if vs if then

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Daniel Berger

Posts: 1383
Nickname: djberg96
Registered: Sep, 2004

Daniel Berger is a Ruby Programmer who also dabbles in C and Perl
if vs if then Posted: Nov 19, 2007 10:16 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Daniel Berger.
Original Post: if vs if then
Feed Title: Testing 1,2,3...
Feed URL: http://djberg96.livejournal.com/data/rss
Feed Description: A blog on Ruby and other stuff.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Daniel Berger
Latest Posts From Testing 1,2,3...

Advertisement
I generally despise 'then' after an 'if' clause in Ruby, because Ruby doesn't need it and it clutters up my screen.

However, I've discovered that there is one case where I do like to use it, and that's multi-line if statements. Sometimes they're unavoidable, and the 'then' serves as a useful line break that denotes where the clause ends and the conditional code begins.

Consider:
if opts['failure_reset_period'] || opts['failure_reboot_message'] ||
   opts['failure_command'] || opts['failure_actions']
   configure_failure_actions(handle_scs, opts)
end

vs
if opts['failure_reset_period'] || opts['failure_reboot_message'] ||
   opts['failure_command'] || opts['failure_actions']
then
   configure_failure_actions(handle_scs, opts)
end

I'm all about aesthetics. :)

Read: if vs if then

Topic: WWF Canada Advertisement Previous Topic   Next Topic Topic: JRuby Talk Up On Rubyology

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use