INNER CODE UNIT · Swift

encode

a2/swift-shortcuts · Sources/SwiftShortcuts/Actions/Calculate.swift:38

        func encode(to encoder: Encoder) throws {
            var container = encoder.container(keyedBy: CodingKeys.self)

            switch base.calculation {
            case .add(let lhs, let rhs):
                try container.encode(lhs, forKey: .lhs)
                try container.encode(Operation.add, forKey: .operation)
                try container.encode(rhs, forKey: .rhs)
            case .subtract(let lhs, let rhs):
                try container.encode(lhs, forKey: .lhs)
                try container.encode(Operation.subtract, forKey: .operation)
                try container.encode(rhs, forKey: .rhs)
            case .multiply(let lhs, let rhs):
                try container.encode(lhs, forKey: .lhs)
                try container.encode(Operation.multiply, forKey: .operation)
                try container.encode(rhs, forKey: .rhs)
            case .divide(let lhs, let rhs):
                try container.encode(lhs, forKey: .lhs)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…