Skip to content

Instantly share code, notes, and snippets.

@jccarbonfive
Created July 16, 2012 20:49
Show Gist options
  • Select an option

  • Save jccarbonfive/3124947 to your computer and use it in GitHub Desktop.

Select an option

Save jccarbonfive/3124947 to your computer and use it in GitHub Desktop.
# What is your preferred formatting?
# a.)
if bar
foo = 'baz'
else
foo = 'bax'
end
# b.)
foo = if bar
'baz'
else
'bax'
end
# c.)
foo = if bar
'baz'
else
'bax'
end
# d.)
foo = bar # refactor conditional to a method
@Empact
Copy link

Empact commented Jul 16, 2012

I like the ternary but my preferred block assignment spacing is:

foo =
  if bar
    'baz'
  else
    'bax'
  end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment