Project

General

Profile

Actions

Feature #20444

closed

Kernel#loop: returning the "result" value of StopIteration doesn't work when raised directly

Added by esad (Esad Hajdarevic) 7 months ago. Updated 7 months ago.

Status:
Feedback
Assignee:
-
Target version:
-
[ruby-core:117646]

Description

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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0