This is my blog. It contains my ideas, insights, or other stuff of software development that I believe are worth to be written down. I hope these notes will be helpful for others as well. As software developers we discover exciting features and new possibilities of coding almost every day. And this blog aims to make the things that I have discovered open source.
Lately I have read two very inspiring articles about sequences in Swift. Both articles use the sequence of Fibonacci numbers as an example of an unlimited and lazily evaluated sequence. In a lazy sequence its elements are not generated until their processing. However, there are some pitfalls that need to be avoided when working with such sequences.
Recently I had to explain recursive functions to my students. One of the examples was the recursive formula for Binomial Coefficients which can be visualized as Pascal's triangle. Looking for a real world problem that can be solved by using Pascal's triangle I found the shortest grid path problem. Since I'm currently trying to get familiar with programming in Swift, I thought to myself, why not coding something in Swift that computes these paths?
Have you ever wondered how to test enumerations with associated values easily in Swift? The point is that you can do all sorts of pattern matching with enums, but you cannot express a simple expectation in a single line. Well, with a little help from a function, you actually can.
Optional chaining in Swift is a means to safely access properties of potential
nil values using the
?. operator. This concept is also known in other languages, particularly in
which provide the «safe navigation operator».
However, there is a subtle difference between Groovy's and Swift's implementation.