class Deck
attr_accessor :all
def initialize
@all = [1,2,3]
end
end
newdeck = Deck.new
puts newdeck.all
class Testdeck
attr_accessor :cards
def initialize
@cards = []
counter = 0
['H','C', 'S', 'D'].product(['2','3','4','5','6','7','8','9','10','J','K','Q','A']).each do |arr|
@cards << Card.new(arr[0], arr[1])
end
end
end
zen = Testdeck.new
puts zen.cards.pop
这段代码给了我:'block in initialize' uninitialized constant Testdeck NameError
感谢所有帮助。