Actions
Feature #22485
closedensure modifier
Feature #22485:
ensure modifier
Status:
Rejected
Assignee:
-
Target version:
-
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
- 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