This file contains 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
extension String: Monoid { | |
static var neutral: String = "" | |
func operation(_ other: String) -> String { | |
self + other | |
} | |
} |
This file contains 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
protocol Monoid { | |
static var neutral: Self { get } | |
func operation(_ other: Self) -> Self | |
} |
This file contains 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
class Coordinator: FirstControllerDelegate { | |
let window: UIWindow | |
var navigation: UINavigationController? | |
lazy var firstViewController: FirstViewController = { | |
let controller = FirstViewController() | |
controller.delegate = self | |
return controller | |
}() | |
This file contains 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
func goodMorning(morning: Bool, whom: String) { | |
if morning { | |
print("Good morning, \(whom)") | |
} | |
} | |
goodMorning(morning: true, whom: "Pavel") | |
goodMorning(morning: false, whom: "John") |
This file contains 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
func goodMorning(morning: Bool, whom: String) { | |
if morning { | |
print("Good morning, \(whom)") | |
} | |
} | |
func giveAname() -> String { | |
print("giveAname() is called") | |
return "Robert" | |
} |
This file contains 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
func goodMorning(morning: Bool, whom: @autoclosure () -> String) { | |
if morning { | |
print("Good morning, \(whom())") | |
} | |
} | |
func giveAname() -> String { | |
print("giveAname() is called") | |
return "Robert" | |
} |
This file contains 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
func goodMorning(morning: Bool, whom: () -> String) { | |
if morning { | |
print("Good morning, \(whom())") | |
} | |
} | |
func giveAname() -> String { | |
print("giveAname() is called") | |
return "Robert" | |
} |
This file contains 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
var isDebug = true | |
func assert(_ condition: @autoclosure () -> Bool, _ message: @autoclosure () -> String) { | |
guard isDebug else { return } | |
if condition() { | |
print(message()) | |
} | |
} |
This file contains 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
func assert(_ condition: @autoclosure () -> Bool, _ message: @autoclosure () -> String) { | |
if condition() { | |
print(message()) | |
} | |
} | |
func conditionOne() -> Bool { | |
return true | |
} |
NewerOlder