From: Robert Klemme Date: 2013-02-27T23:07:09+09:00 Subject: Re: Why `10` not returned without the `return` from the block ? On Wed, Feb 27, 2013 at 2:36 PM, Love U Ruby wrote: > CODE - I > > class Fixnum > alias other_s to_s > def to_s > a = self + 5 > return a.other_s > end > end > #=> nil > puts 5 > 10 > #=> nil > > CODE - II > > class Fixnum > alias other_s to_s > def to_s > self + 5 > #return a.other_s > end > end > > puts 5 > # > #=> nil > > What I know that block returns automatically its last expression. Why > does `10` not the returned > here, rather `#`? > > But with the `return a.other_s` `10` printed - what is the concpetual > difference between CODE-I and CODE - II? Come on, that's really simple: You do not invoke #other_s. robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/