Writing unit tests often means fixing unit tests. In this video we will walk you through the process.
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/3530-testing-in-ios/lessons/7
Writing unit tests often means fixing unit tests. In this video we will walk you through the process.
Hi Brian, first of all Thanks for this awesome course, I was always looking for something as amazing as this, I just have a question about the multiple operations you assing to the constant βop1β this because it looks like a ternary operators, but I really donβt understand your syntax, principally why they have this symbols β:β , β?β β¦ thanks in advance and have a great day
It is indeed a ternary operator, but that line chains multiple ternary operations together, I believe the code in question is:
let op1 = op == "-" ? "β" : op == "/" ? "Γ·" : op == "*" ? "Γ" : op
It might make better sense if I re-wrote it with brackets to indicate the multiple ternary operations?
let op1 = op == "-" ? "β" : (op == "/" ? "Γ·" : (op == "*" ? "Γ" : op))
Or, you can write the same as if conditions like this:
var op1 = ""
if op == "-" {
op1 = "β"
} else if op == "/" {
op1 = "Γ·"
} else if op == "*" {
op1 = "Γ"
} else {
op1 = op
}
Oh man! Thank you so much, with the last condition way to write it I totally understand it, Thanks again, itβs really helpful
What are the two symbols are you using for subtraction? Is one a symbol and one a hyphen?
@rramirez What symbols are you talking about exactly?
We modify the evaluate method to change a hyphen to a minus sign. On line 2 how do I distinguish between a minus sign and a hyphen?
let type = Type.typeFor(tag: 103)
let op1 = op == β-β ? βββ : op == β/β ? βΓ·β : op == β*β ? βΓβ : op
_ = evaluate(op: op1, arg: arg1, type: type)
let res = evaluate(op: β=β, arg: arg2, type: type)
return res