LaurentL
LaurentL

Reputation: 213

uninitialized constant Die (NameError)

I'm receiving an Uninitialized constant error from my code. I have searched around with no luck. Any help would be highly appreciated.

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

Upvotes: 0

Views: 210

Answers (1)

Matt
Matt

Reputation: 20766

  1. Change Class to class
  2. Add an extra end at the end of the class definition. Looks like you're not closing the while loop.

Upvotes: 2

Related Questions