改编自此链接的示例。不知道调用有什么问题Logger.create.id
,还是我应该l = Logger.new
先调用?
class Logger
private_class_method :new
@@logger = nil
def Logger.create
@@logger = new unless @@logger
@@logger
end
end
Logger.create.id
改编自此链接的示例。不知道调用有什么问题Logger.create.id
,还是我应该l = Logger.new
先调用?
class Logger
private_class_method :new
@@logger = nil
def Logger.create
@@logger = new unless @@logger
@@logger
end
end
Logger.create.id