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

39 out 41 #210

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

39 out 41 #210

wants to merge 4 commits into from

Conversation

y0m0
Copy link

@y0m0 y0m0 commented Jun 25, 2017

No description provided.

@@ -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/, "") }

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

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 }

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? }

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants