From: Esh Gun Date: 2013-05-13T23:03:25+09:00 Subject: Basic question about blocks Hello forum, I am new to Ruby and have a question about blocks. A) Below is the code I have put in a file : --------------------------------------------------- # Script block2.rb def simpleFunction yield yield end animals { |x| puts "Hello, #{x}" } animals { |x| puts "It's #{x.length} characters long!" } --------------------------------------------------- B) I run the as below....only once: --------------------------------------------------- C:\RUBYEX~1>blocksexample.rb --------------------------------------------------- C) The output is as below: --------------------------------------------------- Hello, Tiger Hello, Giraffe It's 5 characters long! It's 7 characters long! --------------------------------------------------- Question 1: How is it I am not getting error for using same name for 2 blocks in the same file? Question 2: How is the first animal block executed followed by the second animal block execution...inspite of me running the example only once... Please let me know, appreciate your help in advance. Esh -- Posted via http://www.ruby-forum.com/.