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 Player: CustomDebugStringConvertible { | |
var number: Int | |
var name: String | |
var debugDescription: String { "Player {number=\(number), name= \(name)}" } | |
} | |
func keyPaths<R, T>(_ base: R, kp: KeyPath<R, T>) { | |
let value = base[keyPath: kp] | |
print("kp value: \(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 S1 { | |
private var _buffer: [UInt8] = [] | |
var values: [UInt8] { | |
get { _buffer } | |
_modify { | |
yield &_buffer | |
} |
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 <vector> | |
template <typename T> | |
T adder(T t) { | |
return t; | |
} | |
template <typename T, typename ... Args> |
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 Quick | |
import Nimble | |
@testable import FormulaOne | |
class TestPitStop: QuickSpec { | |
var car: Car? | |
var service: CarService = CarService() | |
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 Quick | |
import Nimble | |
@testable import FormulaOne | |
class TestPitStop: QuickSpec { | |
var car: Car? | |
var service: CarService = CarService() | |
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
fun getUser(usid: String) { | |
apiToken { // it: String | |
findUser(usid: it) { //it: User | |
// Do what you want with the user. | |
} | |
} | |
} |
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
fun hi() = sequence { // this: SequenceScope<String> | |
yield("Hi") | |
yield(":))") | |
} | |
val words = hi() | |
for (word in words) { | |
println(word) | |
} |
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 getUser(userid: String, continuation: Continuation) | |
suspend fun getUser(usid: String) { | |
// label: 0 | |
val token = apiToken(sm) | |
// label: 1 | |
val user = findUser(usid, sm.token, sm) | |
// label: 2 | |
// Do what you want with the user | |
} | |
} |
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
suspend fun getUser(usid: String) { | |
val token = apiToken() | |
val user = findUser(usid, token) | |
} |
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 getUser(userid: String, continuation: Continuation) | |
suspend fun getUser(usid: String) { | |
val sm = CoroutineImpl {} | |
when (sm.label) { | |
0 -> { | |
apiToken(sm) | |
sm.label = 1 | |
} | |
1 -> { |