Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

triple equals swift


import UIKit


class TripleEqualsExample : Equatable {
    let value: Int
     

    init(value: Int) {
        self.value = value
    }

    static func == (lhs: TripleEqualsExample, rhs: TripleEqualsExample) -> Bool {
        return lhs.value == rhs.value
    }
}



class TripleEqualsExampleViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        self.view.backgroundColor = .white

        ///Triple Equals check that both object's reference is same or not.
        
        let instances1 = TripleEqualsExample(value: 5)
        let instances2 = TripleEqualsExample(value: 5)
        
        let instances3 = instances1

        if instances1 == instances2 {
           print("the two instances are equal!")
        }
        
        
        if instances1 === instances2 {
           //It does not enter here
        } else {
           print("the two instances are not identical!")
        }
        
        
        if instances3 === instances1 {
           print("the two instances are identical!")
        }
    }

}
Comment

PREVIOUS NEXT
Code Example
Swift :: swiftui refresh view 
Swift :: Optional & Default Parameter Swift 
Swift :: swift reload view 
Swift :: check if UIView is UIButton or UILabel not 
Swift :: Swift Use of Hash Function 
Swift :: Swift Double 
Swift :: bold world in text swift 
Swift :: xcode how to get aspect ratio of device 
Swift :: Log httpurlresponse swift 
Swift :: Swift for Loop inside a while Loop 
Swift :: Swift Generic Function 
Swift :: how to darken view swiftui 
Swift :: Swift Library Function 
Swift :: swift multiline comment 
Swift :: func collectionview 
Swift :: Generic Function Swift 
Swift :: swift uknow attrubute main 
Swift :: swift dictionary to json string online 
Swift :: key path expression as functions ios swift 
Swift :: swiftui orientation failed after change orientation popup 
Swift :: swift function parameters 
Swift :: swift Equatable 
Ruby :: turn an array of string into integer in ruby 
Ruby :: rails generate model 
Ruby :: ruby replace certain character 
Ruby :: run a specific migration rails 
Ruby :: check rails version 
Ruby :: ruby hash merge 
Ruby :: how to add to an array ruby 
Ruby :: rails array count occurrences of elements 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =