From: Esh Gun Date: 2013-05-14T00:00:21+09:00 Subject: Re: Basic question about blocks 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/.