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.
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