Skip to content

Commit

Permalink
Avoid unless
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed May 6, 2012
1 parent 73c8299 commit d368646
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion templates/guests/debian/network_dhcp.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# The contents below are automatically generated by Vagrant. Do not modify.
auto eth<%= options[:interface] %>
iface eth<%= options[:interface] %> inet dhcp
<% unless options[:use_dhcp_assigned_default_route] %>
<% if !options[:use_dhcp_assigned_default_route] %>
post-up route del default dev $IFACE
<% end %>
#VAGRANT-END

2 comments on commit d368646

@nwjsmith
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious, why avoid unless?

@mitchellh
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is just personal style. I honestly think that unless is clearer in some cases (perhaps including this), but the line becomes blurry very quickly:

  • If there is an else
  • If there are multiple boolean expressions being combined unless foo && bar
  • If the boolean expression reads as a negative unless not_foo

if expressions fall under the same problems, but as programmers we're generally trained to understand if rather intuitively, so I tend to avoid the potential unless mess in the future by using only if statements.

I'm not religious about it except in my own code, and I won't argue with someone about it (its just not that important), but I do my best to only use ifs.

Please sign in to comment.