3
在瀏覽StackOverflow的我偶然發現了以下的答案:爲什麼箱子在這裏?
https://stackoverflow.com/a/3817367/162694
// ... removed unneeded code
/// This type is intended for private use within Singleton only.
type private SyncRoot = class end
type Singleton =
[<DefaultValue>]
static val mutable private instance: Singleton
private new() = { }
static member Instance =
lock typeof<SyncRoot> (fun() ->
// vvv
if box Singleton.instance = null then
// ^^^
Singleton.instance <- Singleton())
Singleton.instance
誰能闡述爲什麼這裏的box
需要?