From: "esad (Esad Hajdarevic) via ruby-core" Date: 2024-04-26T10:07:27+00:00 Subject: [ruby-core:117726] [Ruby master Feature#20444] Kernel#loop: returning the "result" value of StopIteration doesn't work when raised directly Issue #20444 has been updated by esad (Esad Hajdarevic). nobu (Nobuyoshi Nakada) wrote in #note-9: > That example does not need `Ractor`. Yes, you are right, it actually doesn't need Thread either, and is simply about calling a block in a loop and how to break the loop from the called block: `proc { break 3}.then { |p| loop { p.call() }}` raises exception, and `proc { raise StopIteration, 3 }.then { |p| loop { p.call() }}` returns `nil`, etc. ---------------------------------------- Feature #20444: Kernel#loop: returning the "result" value of StopIteration doesn't work when raised directly https://bugs.ruby-lang.org/issues/20444#change-108134 * 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/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/