From: fighterlyt Date: 2011-07-14T18:58:53+09:00 Subject: Re: Why return(XXX) is valid within a "value = case N ..." ? 于 2011年07月14日 17:38, Iñaki Baz Castillo 写道: > If you use a "case" expression because > > it should yield a value (i.e. "x = case...end") then I would only use > > exceptions as other way out. A "return" indicates regular execution > > flow which in the case of this usage of "case" would mean "have case > > return a value" but not "return from the method". Remember all the block in ruby is actually a snippet ,so return from the block will return from the method which call the block. For example,type the following code in irb value =case 123 when Fixnum return "good" end LocalJumpError: unexpected return The real reason for your question is that, everything in ruby has a value, include statements. When return statements works, it yield a value which is the result of the invocation, the assignment doesn't happen. value=2 def test2 value=case 123 when Fixnum return 3 end end test2 p value #output 2