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

Passes the spec, but I can still see some potential issues #17

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

Conversation

gwadej
Copy link

@gwadej gwadej commented Oct 1, 2015

Got this one finished to spec. @chivygab, @jaybobo Read for a code review.

@jaybobo
Copy link
Member

jaybobo commented Oct 1, 2015

👍 what are the potential issues?

@gwadej
Copy link
Author

gwadej commented Oct 1, 2015

@jaybobo
No checks for non-word characters in the supplied word.
No escaping of regex metacharacters in the supplied word.
Does not catch the case when the the character immediately to the left or right of the word is a digit.

That's all I can think of off the top of my head. If I took a little time to go into tester mode I might be able to come up with some more.

Like no check for empty string or nil.

@gwadej
Copy link
Author

gwadej commented Oct 6, 2015

As suggested by Jay: Please review @mikegee

@@ -1,3 +1,4 @@
def word_in_string?(word, string)
# implement with your code here
string.match( /(?:\b|_)#{word}(?:\b|_)/ ).nil? ? :no : :yes
Copy link
Member

Choose a reason for hiding this comment

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

Does it work the same if you drop the .nil? and switch the yes/no?

Copy link
Author

Choose a reason for hiding this comment

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

I had a problem earlier that the nil? fixed.
It apparently doesn't apply now.

Removed.

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.

3 participants