From: Bertram Scharpf Date: 2009-12-09T03:50:22+09:00 Subject: Re: Example Ruby Code Hi, Am Mittwoch, 09. Dez 2009, 02:30:58 +0900 schrieb Christopher Davidson: > Can anybody explain how this code actually works in simple terms if > possible :). > > def animals > yield "Tiger" > yield "Giraffe" > end > > animals { |x| puts "Hello, #{x}" } That's short for def animals &block block.call "Tiger" block.call "Giraffe" end b = proc { |x| puts "Hello, #{x}" } animals &b Bertram -- Bertram Scharpf Stuttgart, Deutschland/Germany * Discover String#notempty? at .