Project

General

Profile

Actions

Feature #22485

closed

ensure modifier

Feature #22485: ensure modifier

Added by UlyssesZhan (Ulysses Zhan) about 1 month ago. Updated 9 days ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:127273]

Description

Similar to the rescue modifier, an ensure modifier allows writing ensure block in one line: do_something ensure clean_up.

Updated by matz (Yukihiro Matsumoto) 9 days ago Actions #1 [ruby-core:127617]

  • Status changed from Open to Rejected

I am not going to accept this proposal.

ensure is for cleanup that spans multiple statements after acquiring a resource. Attaching cleanup to a single expression is rare, and methods that take a block usually cover that case. The value would also be confusing. With the rescue modifier the right-hand side becomes the value, but with ensure it would be discarded.

The rescue modifier itself is a frequent source of confusion, so I don't want to add another modifier of the same kind. The benefit does not justify new syntax.

Matz.

Actions

Also available in: PDF Atom