In addition to if, for, and while loops, Kotlin also has a control flow option called when. The ‘when’ expression acts just like a switch operator you might see in other languages. The basic structure looks like this: Some notes about this switch structure: The first line uses the key word when followed by a … Continue reading Kotlin: How to use the ‘when’ expression
Kotlin
Kotlin: How to use .filter( ), ‘it’ key word, and arrow ‘->’ operator
Kotlin’s built-in .filter() function is meant to iterate through any iterable collection type, (lists, sets, or maps) and check each element of the collection against some criteria (aka “predicate”). If the element matches the predicate, meaning the boolean result is true, then the element is added to a result collection of the same type that … Continue reading Kotlin: How to use .filter( ), ‘it’ key word, and arrow ‘->’ operator
Kotlin: How to understand the not-null assertion operator (!!)
The Kotlin “not-null assertion operator” is expressed as two exclamation points. !! that appear at the end of a variable name. For example: myVariable!! Here is what the Kotlin documentation says about this operator: Here is what I learned about the not-null assertion operator after a little bit of experimentation: The difference between b and … Continue reading Kotlin: How to understand the not-null assertion operator (!!)
Python and Kotlin: A comparison of the language basics
In this table I will compare some basic programming syntax and conventions between the Python and Kotlin programming languages. Programming element Python Kotlin Commenting code: # This is a comment // This is a comment Multi-line comments: “”” This is a comment. This is a comment, too. This is a comment, too. “”” /* This … Continue reading Python and Kotlin: A comparison of the language basics
Kotlin: How to test your code online
Here are some online web apps that people have written that make it possible to test your Kotlin code online. play.kotlinlang.orghttp://play.kotlinlang.org/ JDOODLEhttp://jdoodle.com/ tutorialspointhttps://tutorialspoint.com
Kotlin: How to create a simple Hello World app
When starting on the journey of learning the Kotlin language, it is a good idea to get an initial impression of the language by creating and running the simplest possible program in Kotlin. That is what I will describe how to do in this article. The first step assumes that you have already downloaded and … Continue reading Kotlin: How to create a simple Hello World app