0

コードから Uninitialized 定数エラーが発生します。私は運が悪いと周りを探しました。どんな助けでも大歓迎です。

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. Classに変更class
  2. endクラス定義の最後にエクストラを追加します。whileループを閉じていないようです。
于 2014-07-02T19:59:55.430 に答える