- テスト駆動開発 の感想
()
は感想
- どのようなクラスから始めるかではなくテストから始める
import SwiftUI | |
extension EnvironmentValues { | |
struct AccessTokenKey: EnvironmentKey { | |
static var defaultValue: String? { | |
nil | |
} | |
} | |
var accessToken: String? { |
//: Playground | |
import Combine | |
let publisherA = (1...4).publisher | |
let publisherB = publisherA.map { $0 * 100 } | |
_ = Publishers.CombineLatest(publisherA, publisherB) | |
.print() | |
.sink(receiveValue: { |
name: CI | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
textlint: |
import Foundation | |
protocol UseCase where Failure: Error { | |
associatedtype Parameters | |
associatedtype Success | |
associatedtype Failure | |
func callAsFunction(_ parameters: Parameters, completion: ((Result<Success, Failure>) -> ())?) | |
} |
/*: | |
# EnvironmentValuesはSubViewに伝搬するしカスタムなKeyも指定できる | |
- EnvironmentValuesは特定のKeyに対して値を設定できる | |
- 標準のKey | |
- https://developer.apple.com/documentation/swiftui/environmentvalues | |
- EnvironmentValuesが特定のViewの項目にそのまま紐付いている | |
- 例えば標準のKeyである\.fontはView上のTextのfontと結びついている | |
- Keyの値がView暗黙的にバインディングされている感じ |
import PlaygroundSupport | |
import SwiftUI | |
import Combine | |
class ObservableObject1: ObservableObject { | |
@Published var name: String = "src" | |
} | |
struct ContentView1: View { | |
@ObservedObject private var object = ObservableObject1() |
()
は感想class Hoge {} | |
// Swift 5から | |
protocol ComponentA: Hoge { | |
func name() -> String | |
} | |
// Swift 4でも同じようなことはできた | |
protocol ComponentB where Self: Hoge { | |
func name() -> String |
fun main(args: Array<String>) { | |
var value: Int? = null | |
println(value ?: 0 < 1) // この出力はtrueです | |
value = 10 | |
println(value ?: 0 < 1) // Q. この出力は何でしょう? | |
} | |
/*: | |
回答の選択肢 | |
- 10 |
var value: Int? = nil | |
print(value ?? 0 < 1) // この出力はtrueです | |
value = 10 | |
print(value ?? 0 < 1) // Q. この出力は何でしょう? | |
/*: | |
回答の選択肢 | |
- 10 |