From: Esh Gun Date: 2013-05-13T23:28:54+09:00 Subject: Re: Basic question about blocks Josh, Sorry for mistake in typing the code...below is the program code... -------------------------------------------- # Script block1.rb def animals yield "Tiger" yield "Giraffe" end animals { |x| puts "Hello, #{x}" } animals { |x| puts "It's #{x.length} characters long!" } -------------------------------------------- And the Yield function in above ... - first yields to the .... animals { |x| puts "Hello, #{x}" } for "Tiger" - then the same "Tiger" should go to the ... animals { |x| puts "It's #{x.length} characters long!" } .... this is my understanding...but the code prints out as below: Hello, Tiger Hello, Giraffe It's 5 characters long! It's 7 characters long! ...Meaning the - first animals block executes for the word "Tiger" and "Giraffe" FOLLOWED BY - second animals block executes for the word "Tiger" and "Giraffe" -- Posted via http://www.ruby-forum.com/.