All pastes #151807 Raw Edit

Someone

public text v1 · immutable
#151807 ·published 2006-08-28 13:02 UTC
rendered paste body
class Lego

        attr_reader :picks
        def self.count; @count = 0; end
        def initialize( *picks )
                if picks.uniq.length != 1
                        raise ArgumentError, "numbers not Identical"
                end
                @picks = picks
        end
        def self.new_random
                new( rand( 25 ), rand( 25 ) )
        rescue ArgumentError
                self.count += 1
                retry
        end
end

Lego.new_random
p Lego.count

# output:
# randexp.rb:14:in `new_random': undefined method `count=' for Lego:Class (NoMethodError)
        from randexp.rb:21