Saturday, January 30, 2010

[Rails] Re: "return" from before_save

On Jan 30, 3:40 pm, Ralph Shnelvar <li...@ruby-forum.com> wrote:

> Hitting the Pickaxe book, it says that returns from a block will cause
> this error.  (Why?  I don't know.)
>
> So ... how does one exit gracefully from a block prior to falling off
> the end of the block?


def foo
yield
end

foo { return 1; puts 'return'} #=> LocalJumpError: unexpected return

foo { next 1; puts 'not reached'} #=> 1

Fred

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate