Skip to content

Instantly share code, notes, and snippets.

@pokk
Created July 28, 2017 02:48
Show Gist options
  • Save pokk/b2b81e4776af830877f5f97245378df5 to your computer and use it in GitHub Desktop.
Save pokk/b2b81e4776af830877f5f97245378df5 to your computer and use it in GitHub Desktop.
Other way to expian 'if' and 'unless'

[TOC]

Introduction

How to do

Using if statment

# bad
if some_condition
  do_something
end

# good
do_something if some_condition

# another good option
some_condition && do_something

Using unless statemnt

# bad
do_something if !some_condition

# bad
do_something if not some_condition

# good
do_something unless some_condition

# another good option
some_condition || do_something

You can think condition statement is put the front of a line.

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