From: ulises Date: 2013-05-14T00:38:10+09:00 Subject: Re: Basic question about blocks You call twice the animal function. The first time sent "puts "Hello, #{x}"" as a block and the second time "puts "It's #{x.length} characters long!"". Saludos, Ulises 2013/5/13 Esh Gun : > Joel Pearson wrote in post #1108793: >> Or this: >> >> animals { |x| puts "Hello, #{x}\nIt's #{x.length} characters long!" } > > Ok. Let me undersdtand this... > > 1) I was thinking the in the below function > > -------------------------------------------- > def animals > yield "Tiger" > yield "Giraffe" > end > -------------------------------------------- > > ... calls each of the blocks below with "Tiger" and "Giraffe" > > -------------------------------------------- > animals { |x| puts "Hello, #{x}" } > animals { |x| puts "It's #{x.length} characters long!" } > -------------------------------------------- > > > 2) But I think from all the explanations I got... below might be true > > -------------------------------------------- > animals { |x| puts "Hello, #{x}" } > animals { |x| puts "It's #{x.length} characters long!" } > -------------------------------------------- > > ... calls the function > > -------------------------------------------- > def animals > yield "Tiger" > yield "Giraffe" > end > -------------------------------------------- > > > Does this make any sense ? > > > > Esh > > -- > Posted via http://www.ruby-forum.com/. >