Skip to content

Instantly share code, notes, and snippets.

@zaagan
Created January 27, 2020 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zaagan/dbb8a9c0d189daf27cde06e70b080901 to your computer and use it in GitHub Desktop.
Save zaagan/dbb8a9c0d189daf27cde06e70b080901 to your computer and use it in GitHub Desktop.
Ruby Basics - If Else Operators
cond1 = cond3 = true
cond2 = cond4 = false
if cond1 and cond3 then puts "1" end
if cond1 and not cond3 then puts "2" end
if cond1 or cond2 then puts '3' end
if cond1 && cond3 then puts '1' end
if cond1 && !cond3 then puts '2' end
if cond1 || cond2 then puts '3' end
if (cond1 && cond3) or not (cond2 || cond4) then puts '4' end
if 'string' == 'string' then puts '5' end
if 'string' != 'string' then puts '6' end
# 1
# 3
# 1
# 3
# 4
# 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment