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

Jack Chester Solutions #81

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

Conversation

jack-chester
Copy link

@jaybobo @matt529

@@ -1,5 +1,7 @@
# Implement this in such a way that when called below, detect_anagram will result in true or false.
def canonical(word)
word = word.upcase
word.split("").sort.to_s #split into characters, sort alphabetically, push back into one string.
Copy link
Member

Choose a reason for hiding this comment

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

String#chars is a bit simpler way to split a string into characters.

Copy link
Member

Choose a reason for hiding this comment

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

Is that to_s at the end giving you back the string you think it is? Do we even need this method to return a string?

Copy link
Author

@jack-chester jack-chester Jun 16, 2017

Choose a reason for hiding this comment

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

Ah, each character is individually being converted to a string. Array#join would have been better, although looking back I didn't even need to join the string at all to determine whether or not it was an anagram.

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