Ruby:名为AFTER定义的方法上的未定义方法错误

mar*_*ion -2 ruby

我不确定这里发生了什么......但是我说这样做:

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')
Run Code Online (Sandbox Code Playgroud)

它给了我以下错误:

NoMethodError: undefined method `won_wins?' for main:Object

at top level    in my-file.rb at line 25
Run Code Online (Sandbox Code Playgroud)

为什么它会这样做,即使我在定义之后调用方法?

Hun*_*len 5

你键入won_wins?而不是who_wins?