Now I think I've got it...anagrams, not palindromes.#95
Now I think I've got it...anagrams, not palindromes.#95mshecket wants to merge 2 commits intopaircolumbus:masterfrom
Conversation
I was mistakenly checking for palindromes instead of anagrams, but now I've got it working correctly.
| # that array so that any word that's an | ||
| # anagram of this word will have the same | ||
| # canonical representation. | ||
| return word.downcase.chars.sort |
There was a problem hiding this comment.
Looks a lot better. Nice find on chars.
To make the ruby more idiomatic, omit return whenever possible.
I personally also find this sort of comment unhelpful - you're basically just explaining how the language works to the reader. Your mileage may vary on this one though.
There was a problem hiding this comment.
Thanks very much for the feedback!
I do tend to err on the side of verbose when it comes to comments--still getting a feel for it and what the expectations are for a professional developer. I'm coming from an education background, so I do have an impulse to explain everything as if it were new to the reader.
There was a problem hiding this comment.
Got it. There is a range of commenting styles for professional developers, but I think it's safe to say that this much explanation would be well outside the norm. My personal style is to put all my energy into choosing helpful names for variables, methods, and classes, and structuring things in a way that is easy to understand. If I feel like I need a comment for someone else to understand it, I take that as a sign that I need to work harder at my naming/structure. If work harder at it and I still feel like it won't make sense without the comment, then I leave it. But again that's just one way of doing things.
I just did this one too fast the first time and thought I was making it look for palindromes--and I wasn't even really doing that either. Now I think it's in good shape and all tests pass.