E
EdUarDo
Hi all, I have this code:
class Test
def testA
home_squad = home.squad.to_a
###########################################
# Could improve this?
###########################################
for i in 0...11
home.tactic.set_player(i, home_squad[0])
end
end
end
class Tactic
def set_player(counter_id, player_id)
@counters[counter_id].player_id = player_id
end
end
Having that home.squad is a Hash object, and @counters an Array,
is there an easy way to do what I'm trying to do?
In loop for of testA method I want to change the player_id attribute of
objects contained in @counters array. Could I define an iterator to simplify
the sentence?
class Test
def testA
home_squad = home.squad.to_a
###########################################
# Could improve this?
###########################################
for i in 0...11
home.tactic.set_player(i, home_squad[0])
end
end
end
class Tactic
def set_player(counter_id, player_id)
@counters[counter_id].player_id = player_id
end
end
Having that home.squad is a Hash object, and @counters an Array,
is there an easy way to do what I'm trying to do?
In loop for of testA method I want to change the player_id attribute of
objects contained in @counters array. Could I define an iterator to simplify
the sentence?