Skip to content

Instantly share code, notes, and snippets.

@zakbarlow1995
Last active July 23, 2019 09:28
Show Gist options
  • Save zakbarlow1995/4475a95d8b2b09f351b192820d821555 to your computer and use it in GitHub Desktop.
Save zakbarlow1995/4475a95d8b2b09f351b192820d821555 to your computer and use it in GitHub Desktop.
Overloading Swift Operators: CGFloat * CGSize
import UIKit
func * (lhs: CGSize, rhs: CGFloat) -> CGSize {
return CGSize(width: lhs.width * rhs, height: lhs.height * rhs)
}
func * (lhs: CGFloat, rhs: CGSize) -> CGSize {
return CGSize(width: lhs * rhs.width, height: lhs * rhs.height)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment