Skip to content

Comments

Now I think I've got it...anagrams, not palindromes.#95

Open
mshecket wants to merge 2 commits intopaircolumbus:masterfrom
mshecket:solution
Open

Now I think I've got it...anagrams, not palindromes.#95
mshecket wants to merge 2 commits intopaircolumbus:masterfrom
mshecket:solution

Conversation

@mshecket
Copy link

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.

mshecket and others added 2 commits November 10, 2019 19:51
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
Copy link

Choose a reason for hiding this comment

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

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.

Copy link
Author

Choose a reason for hiding this comment

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

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.

Copy link

Choose a reason for hiding this comment

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

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.

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