Я не уверен, что здесь происходит ... но скажу, что я делаю это:
def who_wins?(choice1, choice2)
if (choice1 == 'R' && choice2 == 'S') || (choice1 == 'S' && choice2 == 'P') || (choice1 == 'P' && choice2 == 'R')
return choice1
elsif choice1 == choice2
return "tie"
else
raise NoSuchStrategyError
end
end
won_wins?('R', 'P')
Это дает мне следующую ошибку:
NoMethodError: undefined method `won_wins?' for main:Object
at top level in my-file.rb at line 25
Зачем это делать, даже если я вызываю метод ПОСЛЕ определения?