Created
December 31, 2017 17:01
-
-
Save rachidcalazans/11ee0d970c9660b96a98beb5fc89e3dd to your computer and use it in GitHub Desktop.
Example I for the Post - avoiding-conditionals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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