20 May '12, 7am

@ponnappa yeah I understood blocks and yield too.. this helped in understanding too

Alle mercoledì 28 gennaio 2009, klochner ha scritto: > > than return, but I don't consider this to be one of them. Anyone care > to weigh in? yield and return do completely different things, and you can't use one in place of the other. return tells ruby to stop executing the method and return its argument to the caller. yield tells ruby to call the block passed to the method, giving it its argument. yield will produce an error if the method wasn't called with a block: def test_yield yield 43 end test_yield # notice that no block was passed to the method => LocalJumpError: no block given In ruby, there's no need to put a return at the end of a method, as the method will always return the value of the last expression. This means that a method defined this way: def test_return return 4 end will give exactly the same result as a method defined this way: def test_no_return 4 en...

Full article: http://www.ruby-forum.com/topic/177007

Tweets

block_given? vs defined? yield - Ruby Forum

ruby-forum.com 21 May '12, 12am

On Feb 8, 2006, at 12:01 PM, Yukihiro Matsumoto wrote: > might be a little bit faster, but practically you can consider th...

Sri Lanka's Fonseka to return to politics?

Sri Lanka's Fonseka to return to politics?

channelnewsasia.com 20 May '12, 5am

COLOMBO: The release of Sri Lanka's jailed former army chief Sarath Fonseka on Monday could see him return to the country'...