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

Feature/fp #3

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

Feature/fp #3

wants to merge 2 commits into from

Conversation

BulatNsbln
Copy link
Owner

No description provided.

def rating(_array)
0
def rating(array)
hash = { country: 'country', rating: 'rating_kinopoisk' }

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?

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

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тоже самое тут, лишний код, который не добавляет понятности

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

Successfully merging this pull request may close these issues.

2 participants