Smart debugging with Literal Expression in Swift
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.
Bonus Point
When used as default-parameter, they have values of where they are evaluated i.e. the call-site
Thanks for reading.