Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compare CGPoints In swift?

Tags:

swift

I have 2 CGPoint like :

let a : CGPoint = CGPointMake(1, 1)
let b : CGPoint = CGPointMake(1, 1)

if Both are same then I want to do something.

This is just an example but I want to compare this two CGPoint and I found this question which is already asked but this is on objective-C so can anybudy tell me how can I do this is swift?

like image 379
Dharmesh Kheni Avatar asked Dec 07 '22 00:12

Dharmesh Kheni


1 Answers

CGPoint already implements the Equatable protocol, so you can compare using the == operator:

if a == b {
}
like image 83
Antonio Avatar answered Feb 16 '23 08:02

Antonio