Last active
June 1, 2022 08:58
-
-
Save danielctull/40e4fcc5fc3f70980ea582a1cced4e7d to your computer and use it in GitHub Desktop.
Revisions
-
danielctull revised this gist
Dec 3, 2020 . No changes.There are no files selected for viewing
-
danielctull created this gist
Dec 3, 2020 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ // EXAMPLE let string: String? = "Hello World" // String? let unwrappedString = string.really.srsly.itsfine.honestly.aaarggh // String print(unwrappedString) // IMPLEMENTATION extension Optional { var really: Really<Wrapped> { Really(srsly: Srsly(itsfine: ItsFine(honestly: Honestly(aaarggh: { self! })))) } } struct Really<Value> { let srsly: Srsly<Value> } struct Srsly<Value> { let itsfine: ItsFine<Value> } struct ItsFine<Value> { let honestly: Honestly<Value> } struct Honestly<Value> { var aaarggh: Value { getAaarggh() } private let getAaarggh: () -> Value init(aaarggh: @escaping () -> Value) { getAaarggh = aaarggh } }