ruby - create singleton with parameters?
问题 I've seen how to define a class as being a singleton (how to create a singleton in ruby): require 'singleton' class Example include Singleton end But what if I want to give it some parameters for that single instance, meaning, the Example should always have certain properties initialized. For example, say I had a class whose sole purpose is to log to a file (this is just an example) but it requires a name of a file to log to before it can work. class MyLogger def initialize(file_name) @file