# InstanceCheck
在单例类的New方法中调用,目的是保证类的对象唯一。(单例模式)
通常的调用方法如下:
```autohotkey
__New(){
InstanceCheck(this.base)
return this
}
```
### 抛出异常 Throws:
- %异常说明%
### 示例 Example
```autohotkey
Double.base := new Double_Base()
;~ Double.base := new Double_Base()
class Double{
}
class Double_Base{
;~ static InstanceExist := false ;这个可写可不写
;------------------------------
__New(){
InstanceCheck(this.base)
return this
}
} ;---------class Double_Base End
```
```autohotkey
;实例化次数>1会导致
-Stack Trace ~ ~~ Mes:Instance Singleton Class 实例化单例类.
D:\AHKs\ahk_lib\Function.ahk(480) : ==> offset:-1 caller:StackTrace
D:\AHKs\ahk_lib\Function.ahk(490) : ==> offset:-2 caller:throwWithSt
D:\AHKs\ahk_lib\Function.ahk(504) : ==> offset:-3 caller:throw
D:\AHKs\Dev\TPDD_单例类测试.ahk(50) : ==> offset:-4 caller:InstanceCheck
D:\AHKs\Dev\TPDD_单例类测试.ahk(34) : ==> offset:-5 caller:Double_Base.__New
```
- 指南 (README)
- 常见问题 (FAQ)
- 更新历史(CHANGELOG)
- 贡献指南 (CONTRIBUTING)
- 开源协议 (LICENCE)
- 鸣谢 (ACKNOWLEDGEMENT)
- 文档模板 (TEMPLATE)
- 新手指南(BEGINNER_GUIDE)
- 语法高亮(HIGHLIGHTING)
- Class
- _Container
- _EX
- _List
- _Map
- _Win
- _Wins
- BeanEnum
- HotString
- HotStringMaps
- InvisibleCharacter
- JSON
- JsonFile
- Method
- ObservableMap
- ObservableObj
- WinEvent
- Timer
- MesToast
- APPLocker
- AutoClassify
- Everything
- Function
- Ini
- AutoInputBox
- ParaChecker
- PathObj
- RunningSpeedTest
- Script
- Switcher
- Stack
- TimeChecker
- Type
- UMSS
- Function
- assert()
- Analyze()
- AnalyzeClassName()
- AutoBind()
- bulkMoveFile()
- ExcelToList()
- getClass()
- getCurrentTime()
- getFunc()
- Instanof()
- InstanceCheck()
- loadMethod()
- LogPrintln()
- rawCall()
- RandomStr()
- showObj()
- Type()
- throwWithSt()
- UseCMD()
- ObjDump()
- Test
- ObjLoad()
- StringMethod
- TypeClass
- MapFactory()