Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

While I agree with the other comment re premature optimization, when using guard clauses you can also break up your conditions into multiple statements which is arguably the most readable solution. The author’s example could be written as:

  return unless valid_token
  return if expired?
This scales extremely well if you’re concerned about future conditions.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: