From: Justice Me Date: 2009-07-14T18:08:12+09:00 Subject: Array function? PLOT: I want to build a simple card counter function. When i make a object which is the player shall the player got one card (number between 1-13 in type of hearts for example). When more players connect the function has to check that the number not has been given to an player already. So no player can have the same card number. here is the code for the object persons: [code] #create class class Player #set instance variables attr_accessor :name, :card end #create object player = Array.new #loop data into objects for i in (0..12) #create object array player[i] = Player.new player[i].name = "PlayerName#{i}" player[i].card = rand(12) + 1 #Here i don't know the function for this puts "#{player[i].name} #{player[i].card} -----------------" end [/code] -- Posted via http://www.ruby-forum.com/.