Printing logs is the most important while you are debugging. It becomes more challenging when there are different function calls involved in a feature you are debugging.
Most of the developers use random print statements to check how the code flow is behaving e.g.
print(“someFunction -> 1”)
print(“someFunction -> 2”)
and so on….
Here comes Literal Expression
Literal Expression is a source code representation of a value that can be of any possible types in Swift (Int, String, Floating-Point, Boolean, Array or dictionary etc.).
e.g. #file, #function, #line and there are many more.
Now, how to use it
Here I am taking just few basic examples that’ll help you in basic logging.
When used as default-parameter, they have values of where they are evaluated i.e. the call-site
Thanks for reading.
Higher-Order functions; If you have some experience working in swift, you might have used it at several places in your code. A function that takes one or more function as argument is called Higher-Order function.
But here, what I am more interested in explaining is how to write your own Higher-Order function. ( It is hot question for many companies too, so stay tuned ). What I have seen in my experience that this question is put in such a way that it seems complicated when asked, which is not that tricky actually.
Let’s start with this question and answer…
There can be many possible cases when you face two different protocols with same signature of function or name of variable.
Here is the solution, use this
Let’s try some sample code:
XCode scans your all methods written in your test class and tests all which start with ‘test’.
You can be simply disabled just by adding anything before ‘test’.
For example: modify it like this ‘func xyztestBusinessLogic()’ and this test wouldn’t be picked by XCTest.