Skip to content

Instantly share code, notes, and snippets.

@b3ll
Created July 25, 2020 04:37
Show Gist options
  • Save b3ll/afdf32362dcabfafc6d4b0a7975135ee to your computer and use it in GitHub Desktop.
Save b3ll/afdf32362dcabfafc6d4b0a7975135ee to your computer and use it in GitHub Desktop.
Floating Point Stuff
public protocol ScalableValue: ExpressibleByFloatLiteral {
func scaled(by: Double) -> Self
}
public extension ScalableValue where Self: FloatingPoint {
func scaled(by constant: Double) -> Self {
return self * constant
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment