Recently, I found different bridging between Array and Dictionary. In the following code, I tried to check an address of instances being created by implicitly bridging of Array and Dictionary.
As you can see, dic
is passed into unsafeAddressOf
function which prints an address of an instance of AnyObject
passed. It's expected to be converted to NSDictionary when it passed to the function since dic
is a value of Dictionary. As you can easily see, this bridging made new instance of NSDictionary. Based on the result, I presumed that calling the function twice would result in creating two instances of NSDictionary. But, same addresses got printed. It seems that just one instance has been made.
The experiment with NSArray looks work well in my assumption.
Why do they work differently?