How do I check for reference equality in F#?

The answer, it turns out, is to use LanguagePrimitives.PhysicalEquality: let isSameObject = LanguagePrimitives.PhysicalEquality let a = [1; 2; 3] let b = [1; 2; 3] let a’ = a printfn “%A” (isSameObject a b) // Prints “false” printfn “%A” (isSameObject a a’) // Prints “true” There was precisely one question I could find on Stack … Read more

isEqual doesn’t always work for NSIndexPath? What can I use in its place?

As of iOS 5 you can just use isEqual: (see comments) Try [indexPath1 compare: indexPath2] == NSOrderedSame. Maybe you found a bug in NSIndexPath. If you try to create a new NSIndexPath with a path that already exists you should get that one instead. So isEqual: probably just compares the pointers and not the actual … Read more

Equality in Kotlin

Referential Equality Java In Java, the default implementation of equals compares the variable’s reference, which is what == always does: The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and … Read more

Checking equality of interface{}

Thanks to @CodingPickle comment, I provide the following from the Go Programming Language Specification The equality operators == and != apply to operands that are comparable. Regarding interface{}s and structs: Interface values are comparable. Two interface values are equal if they have identical dynamic types and equal dynamic values or if both have value nil. … Read more

tech