
Issue #21160 has been updated by ufuk (Ufuk Kayserilioglu). `next` isn't necessarily the correct thing to use here, `break` is: ```ruby foo = fulfills_promise :generate_large_image do |image_data| break false if image_data.nil? puts 'Saving image..' # etc. end foo #=> false ``` And the name exactly conveys the concept of breaking out of the block, in my opinion. For example: ```ruby result = (1..100).each do |num| break num if num > 3 puts num end puts "Got result #{result}" ``` will print ``` 1 2 3 Got result 4 ---------------------------------------- Feature #21160: Local return from proc https://bugs.ruby-lang.org/issues/21160#change-112120 * Author: JustJosh (Joshua Stowers) * Status: Open ---------------------------------------- When writing DSL-style helper methods, I often store block arguments as procs to use as callbacks. Using `return` in a proc will return from the context it was created in, which is unsuitable in the following example. Since procs cannot be converted to lambdas, I end up using `next` to return a value from them early. Example: ``` ruby fulfills_promise :generate_large_image do |image_data| next false if image_data.nil? puts 'Saving image..' # etc. end ``` This works but confuses most readers. I propose introducing an alias for it that is more appropriate for this use case. Perhaps `pass` or `continue`? It's worth noting that `return` would work with `fulfills_promise :foo, -> (bar) do`, though it detracts a bit from a DSL's expressiveness. -- https://bugs.ruby-lang.org/