Does anyone know enough about Ruby’s require to tell me if the following is valid syntax:
class Something
def initialize(mode)
case mode
when :one then require 'some_gem'
when :two then require 'other_gem'
end
end
end
s = Something.new
If so, will the require place the gem into the global namespace as it would when at the top of the file?
Yes.
requiredoesn’t have scope, whileloaddoes.