-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/fp #3
base: master
Are you sure you want to change the base?
Feature/fp #3
Conversation
def rating(_array) | ||
0 | ||
def rating(array) | ||
hash = { country: 'country', rating: 'rating_kinopoisk' } |
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.
Зачем выносить названия ключей хеша в другой хеш? Это усложнят читаемость и восприятие сейчас
hash = { country: 'country', rating: 'rating_kinopoisk' } | ||
count = 0 | ||
result = array.select do |film| | ||
next unless film[hash[:rating]].to_f.positive? |
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.
Не инвертируй условия, это усложняет восприятие. В руби как правило есть метод-антоним, используй их
Например, negative?
— антоним positive?
next if film[hash[:rating]].to_f.negative?
Намного проще, потому что не надо в голове выполнять лишнее НЕ
чтобы разобраться что делает код
result = array.select do |film| | ||
next unless film[hash[:rating]].to_f.positive? | ||
next if film[hash[:country]].nil? | ||
next unless film[hash[:country]].split(',').length >= 2 |
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.
Тоже самое тут. Проще понимать условие, если меньше двух
, чем если не больше или равно двум
hash = { name: 'name', rating: 'rating_kinopoisk' } | ||
count = 0 | ||
films.map do |film| | ||
next unless film[hash[:rating]].to_f >= threshold |
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.
Тоже самое тут, не используй unless
def chars_count(_films, _threshold) | ||
0 | ||
def chars_count(films, threshold) | ||
hash = { name: 'name', rating: 'rating_kinopoisk' } |
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.
Тоже самое тут, лишний код, который не добавляет понятности
No description provided.