#encoding: utf-8

class Student
 def initialize(number,name)   #声明构造函数
   @number = number
   @name = name
 end
   attr_accessor :number, :name  
end
def each(stus)
 for stu in stus
   yield(stu)                       #调用each函数的代码块
   puts stu.number+"\t"+stu.name
 end
end
students=Array.new
students[0]=Student.new("1","你")
students[1]=Student.new("2","hao")
students[2]=Student.new("3","aaaa")
each(students) do
 |stu|  stu.number = "stu" + stu.number
end