
Issue #20444 has been updated by ufuk (Ufuk Kayserilioglu). @esad If you just want to return a result from the `loop`, you can use `break <value>` to do that: ``` $ ruby -e "puts loop { break 3 }" 3 ``` You shouldn't have to deal with anything low level like `StopIteration` to do that. ---------------------------------------- Feature #20444: Kernel#loop: returning the "result" value of StopIteration doesn't work when raised directly https://bugs.ruby-lang.org/issues/20444#change-108088 * Author: esad (Esad Hajdarevic) * Status: Feedback ---------------------------------------- There was a https://bugs.ruby-lang.org/issues/11498 a while ago which was merged in, but I was surprised to find out that raising `StopIteration` in a loop like `loop { raise StopIteration.new(3) }` returns nil and not 3. -- https://bugs.ruby-lang.org/