From: ulises Date: 2013-05-13T23:47:10+09:00 Subject: Re: Basic question about blocks The output is correct, to get what you want to change the sentence: animals { |x| puts "Hello, #{x}"; puts "It's #{x.length} characters long!" } Saludos, Ulises 2013/5/13 Esh Gun : > Joel Pearson wrote in post #1108788: >> The order of execution is correct, you're calling "animals" twice, and >> in each case you're getting "Tiger" and "Giraffe" before moving on the >> next call of "animals". > > Sorry but I am trying to understand the flow here... > > 1) First yield "Tiger" should call > animals { |x| puts "Hello, #{x}" } > animals { |x| puts "It's #{x.length} characters long!" } > > 2) Second yield "Giraffe" should call > animals { |x| puts "Hello, #{x}" } > animals { |x| puts "It's #{x.length} characters long!" } > > > But the output is NOT... > Hello, Tiger > It's 5 characters long! > Hello, Giraffe > It's 7 characters long! > > The output IS... > > Hello, Tiger > Hello, Giraffe > It's 5 characters long! > It's 7 characters long! > > -- > Posted via http://www.ruby-forum.com/. >