* [ruby-core:124522] [Ruby Feature#21822] Expose Return Value in the ensure Block
[not found] <redmine.issue-21822.20260103101134.53214@ruby-lang.org>
@ 2026-01-14 2:03 ` nobu (Nobuyoshi Nakada) via ruby-core
2026-02-12 8:13 ` [ruby-core:124785] " matz (Yukihiro Matsumoto) via ruby-core
2026-02-12 20:28 ` [ruby-core:124803] " artemb (Artem Borodkin) via ruby-core
2 siblings, 0 replies; 3+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2026-01-14 2:03 UTC (permalink / raw)
To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)
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/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:124785] [Ruby Feature#21822] Expose Return Value in the ensure Block
[not found] <redmine.issue-21822.20260103101134.53214@ruby-lang.org>
2026-01-14 2:03 ` [ruby-core:124522] [Ruby Feature#21822] Expose Return Value in the ensure Block nobu (Nobuyoshi Nakada) via ruby-core
@ 2026-02-12 8:13 ` matz (Yukihiro Matsumoto) via ruby-core
2026-02-12 20:28 ` [ruby-core:124803] " artemb (Artem Borodkin) via ruby-core
2 siblings, 0 replies; 3+ messages in thread
From: matz (Yukihiro Matsumoto) via ruby-core @ 2026-02-12 8:13 UTC (permalink / raw)
To: ruby-core; +Cc: matz (Yukihiro Matsumoto)
Issue #21822 has been updated by matz (Yukihiro Matsumoto).
I don't think it's not worth for the new syntax, where you can do similar thing with:
```
begin
ret = begin
# ....
end
ensure
LOGGER.debug "return value: #{ret}"
end
```
Matz.
----------------------------------------
Feature #21822: Expose Return Value in the ensure Block
https://bugs.ruby-lang.org/issues/21822#change-116396
* 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/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:124803] [Ruby Feature#21822] Expose Return Value in the ensure Block
[not found] <redmine.issue-21822.20260103101134.53214@ruby-lang.org>
2026-01-14 2:03 ` [ruby-core:124522] [Ruby Feature#21822] Expose Return Value in the ensure Block nobu (Nobuyoshi Nakada) via ruby-core
2026-02-12 8:13 ` [ruby-core:124785] " matz (Yukihiro Matsumoto) via ruby-core
@ 2026-02-12 20:28 ` artemb (Artem Borodkin) via ruby-core
2 siblings, 0 replies; 3+ messages in thread
From: artemb (Artem Borodkin) via ruby-core @ 2026-02-12 20:28 UTC (permalink / raw)
To: ruby-core; +Cc: artemb (Artem Borodkin)
Issue #21822 has been updated by artemb (Artem Borodkin).
> ```
> begin
> ret = begin
> # ....
> end
> ensure
> LOGGER.debug "return value: #{ret}"
> end
> ```
For me, ensure => ret looks cleaner, reduces cognitive overhead, and is simply easier on the eyes when reviewing real code.
The structure is easier to parse visually, and the intent is clearer compared to the alternatives.
Also, it doesn’t break any existing behavior — it’s purely additive, just a small but useful extension that makes the code more elegant and pleasant to read.
----------------------------------------
Feature #21822: Expose Return Value in the ensure Block
https://bugs.ruby-lang.org/issues/21822#change-116419
* 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/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-02-12 20:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <redmine.issue-21822.20260103101134.53214@ruby-lang.org>
2026-01-14 2:03 ` [ruby-core:124522] [Ruby Feature#21822] Expose Return Value in the ensure Block nobu (Nobuyoshi Nakada) via ruby-core
2026-02-12 8:13 ` [ruby-core:124785] " matz (Yukihiro Matsumoto) via ruby-core
2026-02-12 20:28 ` [ruby-core:124803] " artemb (Artem Borodkin) via ruby-core
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).