Kotlin provides a unique type for a range of values. A range has a start and an end value.
To create a range you can use the rangeTo() function.
This code defines a range variable myRange containing values from 1 to 10 inclusive.
Ranges in Kotlin are closed, this mean that the start value and the end value are included in the range.
Continue reading Ranges in Kotlin
The do-while loop first executes the loop statements before evaluating the expression. It means that the statements in a do-while loop will always run at least once, even the condition evaluates to false.
When the program runs, code inside do block is executed once without testing the condition. After that, condition is tested.
Continue reading The do-while loop
Some of the Kotlin’s standard functions are so similar that we are not sure which to use. Here I will introduce a simple way to clearly distinguish their differences and how to pick which to use.
The functions that I’ll focus on is run, with, T.run, T.let, T.also and T.apply. I call them scoping functions as I view their main functionality as provide an inner scope for the caller function.
Continue reading Run, with, let, also and apply
In this tutorial we will learn how to make your own Timer with Start, Pause, Resume and Stop statements. We will use here a Handler, what allows us to send and process message and runnable objects.
To create a timer application, we have more options. For example we can use a Timer or a CountDownTimer.
Continue reading Timer Application with Handler
A Service (like ForegroundService) is an application component that can perform long-running operations in the background, and it doesn’t provide a user interface.
Another application component can start a service, and it continues to run in the background even if the user switches to another application. Additionally, a component can bind to a service to interact with it. For example, a service can handle network transactions, play music, perform file I/O, or interact with a content provider, all from the background.
Continue reading ForegroundService
In most computer programming languages, a while loop is a control flow statement that allows code to be executed repeatedly based on a given Boolean condition. The while loop can be thought of as a repeating if statement.
Continue reading The While Loop