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 DefaultStringInterpolation { | |
| mutating func appendInterpolation<T>( | |
| opt value: T?, | |
| or alternative: @autoclosure () -> String = String(describing: Optional<T>.none) | |
| ) { | |
| if let value { | |
| appendInterpolation(value) | |
| } else { | |
| appendLiteral(alternative()) |
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 Binding { | |
| func bool<T>() -> Binding<Bool> where Value == Optional<T> { | |
| Binding<Bool> ( | |
| get: { | |
| self.wrappedValue != nil | |
| }, | |
| set: { newValue in | |
| // alertはボタンタップで非表示に変化の時にfalseをsetする。 | |
| // その際には、元のOptional値をnilに更新する。 | |
| if !newValue { |
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 Foundation | |
| let s1 = "(Hello, String, か゚か゚か゚)" | |
| print("s1:", s1) | |
| let c1: Character = "A" | |
| let c2: Character = "B" | |
| let s2 = String([c1, c2]) | |
| print("s2:", s2) |