

code in here gets executed if baz was nil in here, numberOfCharacters has a value, and it's type is Int Var biff: Int? = null // "Nullable Int", can be an Int or null Optionals/Nullables Swift var foo: String? = "something"įoo?.count // evaluates to 7, but type is Int? (an Optional Int)įoo!.count // evaluates to 7, and type is Int (not an optional)

Var biff: Int? = nil // "Optional Int", can be an Int or nil Kotlin val foo = 42 // constant Declare Variables Swift let foo = 42 // constant (inferred type Int) Here’s a handy cheat-sheet for anyone who is familiar with one language, and just needs to look up the syntax for doing the same thing in the other language. Fortunately Swift and Kotlin are very similar in a lot of ways, many of the paradigms are the same, just with different syntax. My background is primarily iOS development, though I’ve been dabbling in the Android world in recent years.
