To work effectively with Kotlin, knowing how to initialize a List of lists is important. Also known as a two-dimensional array, or a matrix, a list of lists is a data structure that is defined as a single list where each element is, itself, a list. In this tutorial, we’ll explore...
This article explored ways to remove null and empty values from a List in Kotlin. First, we discussed the programmatic approach involving iterating a list and removing any null or empty elements. Next, we saw how to use built-in methods to achieve the same goal. Remember that while the re...
In thisKotlin Tutorial, we learned how to remove all the elements in a mutable list in Kotlin, using clear() function, with the help of example programs.
Sort a List of Lists in Python Using thelambdaExpression Along With thesorted()Function In addition to the combination ofitemgetter()from theoperatormodule andsorted(), Python offers an alternative method usinglambdaexpressions. This is a concise way to create small, anonymous functions, and it pa...
range()is a Python built-in function that outputs a list of a range of numbers. range(start,stop,step) This function has 3 arguments; the main required argument is the second argumentstop, a number denoting where you want to stop. There are 2 optional arguments,startspecifies where you sh...
A Kotlin List of type Any can store elements of any type. To filter elements of type Integer only, call filterIsInstance() method on this method, with the type T specified as Int for filterIsInstance() function.
(Kotlin) How to Create a Chatbot Last modified: 25 May 2023 What's a chatbot? It's a Space application that communicates with a Space user in its own Chats channel. A minimum viable bot must: Respond with a list of available commands when a user types / (slash) in the channel...
In the last 10 years, more and more languages that run on the JVM have been developed but they look and feel nothing like Java. One such language is Kotlin.
Kotlin propertiesVariables created in a class are properties. The read-only variables have default accessors and mutable variables accessors and mutators. KotlinProperties.kt package com.zetcode class Person { var name:String = "" var age:Int = 0 override fun toString(): String { return "...
Introduction to Kotlin forEach Kotlin forEach is one of the loop statements that are more traditionally used to do other loops like while loops the loops are used to get each other and every element of the collection, list and to perform the actions on each and every elements of the list...