Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sheshtawy #94

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Sheshtawy #94

wants to merge 3 commits into from

Conversation

sheshtawy
Copy link

Hisham Hassan and others added 3 commits June 8, 2018 07:15

upper = /[A-Z]+/
lower = /[A-Z]?[a-z]+/
bye = /\A(BYE ?){3}\z/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These three regular expressions could be extracted to constants, since they are the same every time this method is called.

upper = /[A-Z]+/
lower = /[A-Z]?[a-z]+/
bye = /\A(BYE ?){3}\z/
response = ''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this local variable. Below, you conditionally assign different values to it, but you don't do anything else with response. I'm pretty sure this method will behave the same if you don't have this local variable and just put those three strings in each part of the if/elsif/elsif.

response = 'SPEAK UP SONNY!'
elsif bye.match(input)
response = 'SEE YOU LATER SONNY!'
elsif upper.match(input)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the input matches none of these regular expressions? I think that would happen if there is no letter in the input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants