Skip to content

Instantly share code, notes, and snippets.

@rachidcalazans
Created December 31, 2017 17:01
Show Gist options
  • Save rachidcalazans/11ee0d970c9660b96a98beb5fc89e3dd to your computer and use it in GitHub Desktop.
Save rachidcalazans/11ee0d970c9660b96a98beb5fc89e3dd to your computer and use it in GitHub Desktop.
Example I for the Post - avoiding-conditionals
# If Else Statment
def render_msg(state)
if state == :in_progress
return 'In Progress'
elsif state == :done
return 'Done'
elsif state == :on_review
return 'On Review'
end
end
# Switch case Statment
def render_msg(state)
case state
when :in_progress
return 'In Progress'
when :done
return 'Done'
when :on_review
return 'On Review'
end
end
render_msg(:in_progress) #=> "In Progress"
render_msg(:done) #=> "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment