Hacker News new | past | comments | ask | show | jobs | submit login

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.



Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: