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
extension String: Monoid { | |
static var neutral: String = "" | |
func operation(_ other: String) -> String { | |
self + other | |
} | |
} |
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
protocol Monoid { | |
static var neutral: Self { get } | |
func operation(_ other: Self) -> Self | |
} |
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
var isDebug = true | |
func assert(_ condition: @autoclosure () -> Bool, _ message: @autoclosure () -> String) { | |
guard isDebug else { return } | |
if condition() { | |
print(message()) | |
} | |
} |
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
func assert(_ condition: @autoclosure () -> Bool, _ message: @autoclosure () -> String) { | |
if condition() { | |
print(message()) | |
} | |
} | |
func conditionOne() -> Bool { | |
return true | |
} |
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
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 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
func goodMorning(morning: Bool, whom: () -> String) { | |
if morning { | |
print("Good morning, \(whom())") | |
} | |
} | |
func giveAname() -> String { | |
print("giveAname() is called") | |
return "Robert" | |
} |
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
func goodMorning(morning: Bool, whom: String) { | |
if morning { | |
print("Good morning, \(whom)") | |
} | |
} | |
func giveAname() -> String { | |
print("giveAname() is called") | |
return "Robert" | |
} |
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
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 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
// In the second view-controller | |
let downloader = ImageDownloader() | |
func downloadImages() { | |
let image = self.downloader.download(image: "avatar") | |
self.imageView.image = image | |
//Other code updating all images in the view-controller | |
} |
NewerOlder