-
Notifications
You must be signed in to change notification settings - Fork 395
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
39 out 41 #210
base: master
Are you sure you want to change the base?
39 out 41 #210
Conversation
@@ -208,12 +251,28 @@ def your_birthday_is_on_a_friday_in_the_year(birthday) | |||
# and 1 that is 4 letters long. Return it as a hash in the format | |||
# word_length => count, e.g. {2 => 1, 3 => 5, 4 => 1} | |||
def count_words_of_each_length_in_a_file(file_path) | |||
result = Hash.new 0 | |||
lines = File.readlines(file_path) | |||
words = lines.map(&:split).flatten.map { |words| words.gsub(/\W/, "") } |
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.
Shadowing outer local variable - words.
@@ -200,6 +239,10 @@ def is_a_2014_bank_holiday?(date) | |||
# e.g. january 1st, will next be a friday in 2016 | |||
# return the day as a capitalized string like 'Friday' | |||
def your_birthday_is_on_a_friday_in_the_year(birthday) | |||
until birthday.friday? do | |||
birthday += 31536000 |
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.
Use underscores(_) as decimal mark and separate every 3 digits with them.
end | ||
|
||
# remove instances of nil AND false from an array | ||
def remove_nils_and_false_from_array(array) | ||
array.select { |item| !!item } |
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.
Use reject instead of inverting select.
end | ||
|
||
# remove instances of nil (but NOT false) from an array | ||
def remove_nils_from_array(array) | ||
array.select { |item| !item.nil? } |
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.
Use reject instead of inverting select.
No description provided.