From the course: Moving Your iOS App to Android Using Kotlin

Unlock this course with a free trial

Join today to access over 22,400 courses taught by industry experts.

Similarities and differences from Swift: Basics

Similarities and differences from Swift: Basics

From the course: Moving Your iOS App to Android Using Kotlin

Similarities and differences from Swift: Basics

- [Instructor] The next thing that we're going to do is compare the similarities between Kotlin and Swift. And we've prepared a project in the exercise files under chapter two, under 02_02, and it's called Everyday Kotlin. And we're going to copy that and put that in our projects folder. And let's get the path for this, I'm going to go ahead and open this up. And to begin with, we're just going to have a single class here called similarities. With this, we're going to look at a sample block of code from Swift and try and write its' comparison in Kotlin. Functions in Kotlin are very similar. We can actually just copy this whole block. Paste it in, put the word fun and instead of an arrow here, we're going to do a colon and that's pretty much it for that. The next thing to do is to see how we actually call these functions. And, again we'll just copy this whole block and we'll alter things as we need to. I'm going to say for here, instead of a name colon, you have to do an equals. Or…

Contents