Last active
November 28, 2018 09:45
-
-
Save VladHurma/e7ca5e91ab3687db52b36a8e72935758 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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
commented
Nov 28, 2018
- В Руби отступы 2 пробела - не табы
- Ты многократно вычисляешь максимальный элемент @height.max
- У тебя уже есть индекс элемента @height.index(@height.max), зачем тебе перебор массива вообще?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment