Swift Type Inference Closure Constraints

One of the things that makes writing Swift so fluid is that the Swift type inference system is strong enough for us to write type-safe code from a natural perspective, without having to pepper String and Int everywhere. Even with somewhat complex typing, such as generics, the compiler will know what to do. However, once… Continue reading

Swift Infinite Lists

Swift Evolution Proposal SE-0094 has been implemented in Swift 3, giving us an easy way to create lazy lists based on a starting value and a generator. One particularly cool thing about lazy lists is that you can have an "infinite list" — one that will keep giving you elements for any index. These are… Continue reading

FizzBuzz in Ruby – Extreme Edition

I recently posted a guide to writing FizzBuzz in Ruby without using any conditionals. I focused on functional/declarative programming themes because I felt they were a good model of how I approached the problem, and also because they made certain things easy, like iteration, which would otherwise pose a problem without conditionals. I had a… Continue reading

FizzBuzz Challenge in Ruby – Thinking Functionally

A while ago, one of my coworkers suggested a fun exercise on a Friday afternoon: Solve the (in)famous FizzBuzz interview question…without using any conditional statements. It's a good "thinking outside the box" spin on the exercise, a little brain teaser for devs of all skill levels. There are several ways to do it, but today… Continue reading

Android EditText StyleSpan Behavior

I recently configured an Android EditText to mimic Simplenote's iOS note UI – the first line of text is bold, and anything after that is normal. I had a simple static method to split a string at the first line break: public static String[] splitAtFirstLineBreak(String string) { return string.split("\n", 2); } and I implemented the… Continue reading

Swift Rewrite Redux

After talking with several people and seeing other implementations of the "Swift Rewrite Challenge", I decided to revise my code using a more complete approach. In my first rewrite, I tried to stay true to the original function. This time, I broke the process down into different functions and extensions, and added functionality that I… Continue reading

Swift Rewrite Challenge

A few days ago, Erica Sadun posted a Swift function snippet and then rewrote it in her own style, discussing the changes. I decided to give it a shot, and (without looking at her version!) refactored the original function to suit my taste.

Continue reading