Created
April 22, 2021 11:57
-
-
Save Gernot/9f3595195f37ecb6bb6f2b1ef9160fb6 to your computer and use it in GitHub Desktop.
What is happening here?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
class Foo<Value> { | |
init(value: Value) { | |
self.value = value | |
} | |
let value: Value | |
func doSomething() { | |
print("Generic") | |
} | |
func doSomething() where Value: FloatingPoint { | |
print("Floating point") | |
} | |
} | |
class Bar<Value>: Foo<Value> { | |
func doAnotherThing() { | |
doSomething() | |
} | |
} | |
Foo(value: 1.0).doSomething() //Floating point | |
Foo(value: 1).doSomething() //Generic | |
Bar(value: 1.0).doSomething() //Floating point | |
Bar(value: 1).doSomething() //Generic | |
Bar(value: 1.0).doAnotherThing() //Generic (This should be "Floating Point"!!!!) | |
Bar(value: 1).doAnotherThing() //Generic |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment