[Ruby] Method

information = {
“my name” => “David Ng”,
“country” => “VietNam”

}

def viewMyInformation(result)
puts ” ” + result[“my name”]
puts ” ” + result[“country”]
end

puts “Info:”

viewMyInformation(information)

[RUBY] FOR loop


persons = ["David", "John", "Stephen", "Jon"]

persons.length.times do |person| // person: index value count from 0
puts "i: " + person.to_s
puts "Name: " + persons[person]
end


persons = ["David", "John", "Stephen", "Jon"]

persons.each do |i|  // now i is an element in string array
puts i
end