From: sawadatsuyoshi@... Date: 2019-10-09T05:54:24+00:00 Subject: [ruby-core:95286] [Ruby master Feature#16246] require with an optional block that is evaluated when requiring fails Issue #16246 has been reported by sawa (Tsuyoshi Sawada). ---------------------------------------- Feature #16246: require with an optional block that is evaluated when requiring fails https://bugs.ruby-lang.org/issues/16246 * Author: sawa (Tsuyoshi Sawada) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- I have some code like this: ```ruby begin require "foo" rescue LoadError puts "You need to install foo in order to have the function A work." ... end ``` I request to allow `require` to take a block which is executed when requiring fails. When `require` takes a block, a `LoadError` would not be raised. The code above would then be written like: ```ruby require "foo" do puts "You need to install foo in order to have the function A work." ... end ``` If there is no need to particularly do anything, then it can be like ```ruby require("foo"){} ``` which will cover the use case in https://bugs.ruby-lang.org/issues/14565. -- https://bugs.ruby-lang.org/ Unsubscribe: