0
私は単純なエラーがあることを知っていますが、私はそれを見つけることができません。私はModules/Mixinsを初めて使用しています。どんな助けでも大歓迎です。 Player
クラスの内部ときはinclude Value
、Ruby Mixin Undefined Method
module Value
def this_is
puts "#{self.players_hand} is the players hand"
end
end
require './value.rb'
class Player
include Value
attr_accessor :players_hand
def initialize
@players_hand = 0
end
def value_is
Value.this_is
end
end
require './player.rb'
class Game
def initialize
@player = Player.new
end
def start
puts @player.players_hand
puts @player.value_is
end
end
game = Game.new
game.start
グレート説明私たちはこの方法を変更する必要がある、ということを知って!ありがとう、@ctcherry – Alekx