-
Notifications
You must be signed in to change notification settings - Fork 27
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
Completed #27
base: master
Are you sure you want to change the base?
Completed #27
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
def word_in_string?(word, string) | ||
# implement with your code here | ||
|
||
string_store = string.gsub(/[_-]/,' ').split(/\s/) | ||
if string_store.include? word | ||
return :yes.to_sym | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you're calling #to_sym on something that is already a symbol! |
||
else | ||
return :no.to_sym | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since that if statement is the last thing to be evaluated in the method, the return statements aren't needed. In general, Ruby style is to skip the use of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of using one regex to sub in spaces, and a second one to split on spaces, why not just split on a single, slightly more complicated regex? Also, I'm not sure "string_store" is the best variable name here. Maybe "words_from_string" or something similar?