0

我从我的代码中收到一个未初始化的常量错误。我四处寻找没有运气。任何帮助将不胜感激。

Class Die

    def initialize 

        roll
    end

    def roll

        @num_showing = 1 + rand(6)
    end

    def showing

        @num_showing
    end

    def cheat
        puts "Enter the die # (1-6)"
        @num_showing = gets.chomp
        while @numshowing > 6 and @numshowing < 0

            puts "Enter the die # (1-6)"
            @num_showing = gets.chomp

        end
    end

puts Die.new.cheat
4

1 回答 1

2
  1. 更改Classclass
  2. end在类定义的末尾添加一个额外的。看起来你没有关闭while循环。
于 2014-07-02T19:59:55.430 回答