Skip to content

Instantly share code, notes, and snippets.

@takasek
Created October 4, 2016 09:40
Show Gist options
  • Save takasek/a2c7aece3ab5a56e539e198743c12d2a to your computer and use it in GitHub Desktop.
Save takasek/a2c7aece3ab5a56e539e198743c12d2a to your computer and use it in GitHub Desktop.
やっぱり、他の数値型と違って、Boolをas NSNumberしたときだけは、同値は同一のclassインスタンスになるようだ #CodePiece
let num = 1 as NSNumber
num === num
//true
(num as Int as NSNumber) === (num as Int as NSNumber)
//false
(num as UInt as NSNumber) === (num as UInt as NSNumber)
//false
(num as Double as NSNumber) === (num as Double as NSNumber)
//false
(num as Bool as NSNumber) === (num as Bool as NSNumber)
//true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment