From: "nobu (Nobuyoshi Nakada) via ruby-core" Date: 2026-01-14T02:03:23+00:00 Subject: [ruby-core:124522] [Ruby Feature#21822] Expose Return Value in the ensure Block Issue #21822 has been updated by nobu (Nobuyoshi Nakada). Is the variable `nil` if an exception is raised, even for non-local variable? By analogy with `rescue`, it feels natural for me that the variable is unchanged in that case. ---------------------------------------- Feature #21822: Expose Return Value in the ensure Block https://bugs.ruby-lang.org/issues/21822#change-116082 * Author: artemb (Artem Borodkin) * Status: Open ---------------------------------------- I'd like to propose a simple feature that allows easy access to the return value inside an ensure block. ```ruby begin # ... ensure => ret # ret is nil if an exception is raised LOGGER.debug "return value: #{ret}" end ``` -- 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/lists/ruby-core.ml.ruby-lang.org/