[ruby-core:127273] [Ruby Feature#22485] ensure modifier
Issue #22485 has been reported by UlyssesZhan (Ulysses Zhan). ---------------------------------------- Feature #22485: ensure modifier https://bugs.ruby-lang.org/issues/22485 * Author: UlyssesZhan (Ulysses Zhan) * Status: Open ---------------------------------------- Similar to the `rescue` modifier, an `ensure` modifier allows writing `ensure` block in one line: `do_something ensure clean_up`. -- https://bugs.ruby-lang.org/
Issue #22485 has been updated by matz (Yukihiro Matsumoto). 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. ---------------------------------------- Feature #22485: ensure modifier https://bugs.ruby-lang.org/issues/22485#change-120136 * Author: UlyssesZhan (Ulysses Zhan) * Status: Rejected ---------------------------------------- Similar to the `rescue` modifier, an `ensure` modifier allows writing `ensure` block in one line: `do_something ensure clean_up`. -- https://bugs.ruby-lang.org/
participants (2)
-
matz (Yukihiro Matsumoto) -
UlyssesZhan (Ulysses Zhan)