[ create a new paste ] login | about

Link: http://codepad.org/5teFSKvO    [ raw code | output | fork ]

Ruby, pasted on Dec 1:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Person
	attr_accessor :name,:age
	def initialize(name,age)
		@name=name
		@age=age
	end
end

class People < Array
end

people=People.new
people.push(Person.new("John",27))
people.push(Person.new("Mary",25))
p people.first.name
p people.length
p people.find {|person| person.age < 26}
# Question : any solution that i can use people object like people[0],people[1],.... ?


Output:
1
2
3
"John"
2
#<Person:0x401bf3ec @age=25, @name="Mary">


Create a new paste based on this one


Comments: