Created
January 16, 2017 09:00
-
-
Save anonymous/b14f91074ce8db48eede122a8ad55407 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person | |
def initialize(name,age) | |
@name = name | |
@age = age | |
end | |
end | |
person = {} | |
i = 0 | |
while i < 5 | |
puts "Enter your name:" | |
name = gets.chomp | |
puts "Enter your age:" | |
age = gets.chomp.to_i | |
i += 1 | |
person[name.to_sym] = Person.new(name,age) | |
end | |
person.each do |key,value| | |
puts "Name is #{key}" | |
puts "Age is #{value}" | |
end | |
-------------------------------------- | |
output: | |
Name is ohoh | |
Age is #<Person:0x00000002fd34f8> | |
Name is hehe | |
Age is #<Person:0x00000002fd32a0> | |
Name is heeh | |
Age is #<Person:0x00000002fd3048> | |
Name is hoho | |
Age is #<Person:0x00000002fd2e18> | |
Name is yeyo | |
Age is #<Person:0x00000002fd2bc0> | |
baweaver
commented
Jan 16, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment