Skip to content

Instantly share code, notes, and snippets.

@fogus
Created March 1, 2010 20:31
Show Gist options
  • Save fogus/318779 to your computer and use it in GitHub Desktop.
Save fogus/318779 to your computer and use it in GitHub Desktop.

You may have noticed that our two functions above used different blocks; the first being when and the second if. You will often see one or the other used as a conditional, but it's not always immediately apparent why. In general, the reasons to use when are:

  • There is no else-part associated with the result of a conditional
  • You require an implicit do in order to perform side-effects

The reasons for the use of if would therefor be the inverse of those above.

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