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

Rachel Lyons #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Rachel Lyons #31

wants to merge 1 commit into from

Conversation

rlyons21
Copy link

No description provided.

while i < str.length
if str[i] == str[i+1]
i += 1
elsif str[i+1] == str[i+2]

Choose a reason for hiding this comment

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

Can you say more about your inclusion of this elsif block? What was your thought process for including it? If you comment it out, does your method still function properly? Why or why not?

Copy link
Author

Choose a reason for hiding this comment

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

If the first two characters in a given string are the same, the if statement in the while loop will find when they are no longer the same. Say str = "aaabbbbc". In this case the if statement would run through twice, but the third time the elsif statement would run because "a" != "b". "b" could be the first non-repeated letter, but there has to be a way to check if "b" is followed by another "b" or a different character. This is what the elsif block is for. When the elsif block is commented out the method does not work properly. If str = "aaabbbbc", without the elsif block, the letter "b" would be returned instead of "c".

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