Created
August 19, 2019 16:48
-
-
Save thexande/1f3b33ba902464f9f345bafa9ebc6383 to your computer and use it in GitHub Desktop.
Using emojis as class names.
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 | |
protocol JuiceContaining { | |
var volume: Double { get } | |
var juiceRatio: Double { get } | |
} | |
protocol DrinkProducing { | |
var drinkVolume: Double { get } | |
} | |
extension DrinkProducing where Self: FruitContaining { | |
var drinkVolume: Double { | |
return fruit.volume * fruit.juiceRatio | |
} | |
} | |
protocol FruitContaining { | |
var fruit: JuiceContaining { get } | |
} | |
final class ๐: NSObject, JuiceContaining { | |
let volume: Double = 3 | |
let juiceRatio: Double = 0.33 | |
} | |
final class ๐น<Fruit: NSObject & JuiceContaining>: FruitContaining, DrinkProducing { | |
var fruit: JuiceContaining = Fruit() | |
} | |
let watermellonDrink = ๐น<๐>() | |
print(watermellonDrink.drinkVolume) // => 0.99 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment