Enums

- [Instructor] Next, let's work with some enums.…Enums in Kotlin are pretty easy.…They're pretty basic too.…We'll call this ActionStates.…And we'll say RUN.…Again, it's capitalized,…so it's not like Swift syntax or Swift conventions.…SIT, STAND,…and WAIT.…So that's a basic enum.…We also have something…that is kind of similar to associated values…except that it's assigned at run time,…so you can't associate values after the fact.…

There's other constructs that you can do…to make a Swift enum type class…but with Kotlin, we can associate values…with enum types at compile time.…enum class, call this Color,…and we're going to give these Int values.…And we'll say RED().…And we'll change this to GREEN…and BLUE.…

Getting a lot of errors…because we have not been following the correct syntax yet.…0xFF0000.…GREEN is going to be 0x00ff00.…BLUE is 0x0000ff.…Going to remove that.…So sometimes Kotlin will blow up you.…Don't worry about it.…Just keep coding in.…It will usually resolve itself.…So let's go down and create an example class to work with.…

Resume Transcript Auto-Scroll

Author

Released

10/26/2017

Now that Google has embraced Kotlin—making it an official language on Android— cross-platform development has become a lot simpler. The striking similarities between Swift and Kotlin make maintaining an app across iOS and Android more intuitive. In this course, discover how to leverage your Swift knowledge to learn Kotlin. Instructor Jon Bott covers the basics of Kotlin, highlighting the similarities and differences between Kotlin and Swift by looking at Swift code examples and walking through how to code Kotlin equivalents. He also demonstrates how to work with different database options, and provides an opportunity for you to get hands-on experience using your iOS knowledge to construct an Android UI.