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
// Awesome auto closures | |
class AwesomeType: CustomStringConvertible { | |
init() { | |
print("Initialize") | |
} | |
var description: String { | |
return "Description of an awesome type" | |
} |
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
#include <iostream> | |
#include <array> | |
#include <vector> | |
int main(int argc, const char * argv[]) { | |
std::vector<int> numbers = {0, 2, 1, 4, 5, -2, 4}; | |
std::sort(numbers.begin(), numbers.end(), std::greater<int>()); | |
std::cout << "Descending: " << std::flush; |
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
#include <iostream> | |
#include <array> | |
#include <vector> | |
int main(int argc, const char * argv[]) { | |
std::vector<int> numbers = {0, 2, 1, 4, 5, -2, 4}; | |
std::stable_sort(numbers.begin(), numbers.end(), std::greater<int>()); | |
std::cout << "Descending: " << std::flush; |
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
#include <iostream> | |
#include <array> | |
#include <vector> | |
int main(int argc, const char * argv[]) { | |
std::vector<int> numbers = {0, 2, 1, 4, 5, -2, 3}; | |
std::partial_sort(numbers.begin(), numbers.begin() + 4, numbers.end(), std::greater<int>()); | |
std::cout << "Descending: " << std::flush; |
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
struct Environment { | |
static var mySecretKey: String = Environment.variable(named: "SECRET_ENVIRONMENT_KEY") ?? CI.mySecretKey | |
static func variable(named name: String) -> String? { | |
let processInfo = ProcessInfo.processInfo | |
guard let value = processInfo.environment[name] else { | |
return nil | |
} | |
return value |
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
struct CI { | |
static var mySecretKey: String = "$(SECRET_ENVIRONMENT_KEY)" | |
} |
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
struct CI { | |
static var mySecretKey: String = "hsajeouisauiuoiueiwqoudasjlk" | |
} |
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
@inline(never) | |
func increment<T: BinaryInteger>(_ t: T) -> T { | |
let incremented = t + 1 | |
return incremented | |
} | |
var i: Int = 1 | |
i = increment(i) |
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
@_specialize(exported: true, where T==UInt) | |
func increment<T: BinaryInteger>(_ t: T) -> T { | |
let incremented = t + 1 | |
return incremented | |
} | |
var i: Int = 1 | |
i = increment(i) |
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
@_semantics("optimize.sil.specialize.generic.never") | |
func increment<T: BinaryInteger>(_ t: T) -> T { | |
let incremented = t + 1 | |
return incremented | |
} | |
var i: Int = 1 | |
i = increment(i) |