Skip to content

Instantly share code, notes, and snippets.

@VladHurma
Last active November 28, 2018 09:45
Show Gist options
  • Save VladHurma/e7ca5e91ab3687db52b36a8e72935758 to your computer and use it in GitHub Desktop.
Save VladHurma/e7ca5e91ab3687db52b36a8e72935758 to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
class Find_hihgest_student
def initialize
@height = [180, 210, 172, 180, 239, 168]
@students = %w[Sam Mickle George Genry Will Waldemar]
end
def self.run
new.run
end
def run
say_user_name_of_the_highest_student
end
private
def say_user_name_of_the_highest_student
puts "#{@students[@height.index(@height.max)]} is the highest student!"
end
end
Find_hihgest_student.run
@aya-soft
Copy link

  1. В Руби отступы 2 пробела - не табы
  2. Ты многократно вычисляешь максимальный элемент @height.max
  3. У тебя уже есть индекс элемента @height.index(@height.max), зачем тебе перебор массива вообще?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment