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

Completed #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion parser.rb
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/)
Copy link
Contributor

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?

if string_store.include? word
return :yes.to_sym
Copy link
Contributor

Choose a reason for hiding this comment

The 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

Choose a reason for hiding this comment

The 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 return except for early returns (e.g. guard clauses).