Collections in any language is an interface that stores similar data type objects and provides an iteration functionality. The common extensions of Collection are List and Set.

The Map is a well-known data structure used to store key-value pairs where keys will be unique.

This post was originally posted at https://agrawalsuneet.github.io/blogs/why-map-does-not-extend-collection-interface/ and reposted on Medium on 28th April 2021.

We can take a reference of any language but let’s look at the example of Java for reference as Collection Framework from Java is very popular.

Java has Iterable interface which is extended by Collection. The Collection is further extended by…


Collections are a common concept for most programming languages. It is a way of storing similar data types in a single object and iterate over it. Similar to any other language, Kotlin also has Collection defined in kotlin.collections package.

This post was originally posted at https://agrawalsuneet.github.io/blogs/collections-in-kotlin/ and reposted on Medium on 28th April 2021.

Types of Collection in Kotlin

There are two types of collection in Kotlin

  1. Immutable
    The one which can’t be modified once the object is created. We can just iterate over them or create a copy of them but we can’t modify the actual one.
  2. Mutable These can be modified means that…

Kotlin is a powerful language that reduces a lot of boilerplate code required to perform basic operations in comparison to Java. The classic examples for the same are any, non and all functions which were added to the Iterable interface and Map interface.

This post was originally posted at https://agrawalsuneet.github.io/blogs/any-none-all-kotlin/ and reposted on Medium on 28th April 2021.

Let try to understand what do they do, why they are required and when to use them. But before we begin, I am assuming a basic knowledge of Map, Set and List.

The List provides the functionality to maintain the ordered collection…


if let and guard let are two conditional operators or condition checker which make our life super easy. Other languages have only if as condition checker but swift provides if let as well as guard let also which are operationally the same but a bit different in functionality.

This post was originally posted at https://agrawalsuneet.github.io/blogs/if-vs-if-let-vs-guard-let-in-swift/ and reposted on Medium on 16th Mar 2021.

To understand their differences, let’s try to understand what they are in details first.

if condition

Normal if condition is nothing but to check whether a condition is true or not.

let colors = ["red", "green", "blue"] if colors.contains("red")…

Kotlin is a powerful language that reduced a lot of boilerplate code when compared to Java. The single expression function is the same in terms of reducing the boilerplate code.

The single expression function, as his name suggests, is the function that just has a single expression. We can remove the return type of that function, braces as well as return keyword from it.

This post was originally posted at https://agrawalsuneet.github.io/blogs/kotlin-single-expression-function/ and reposted on Medium on 16th April 2021.

Think about a function that has some calculation to be done based on the passed argument and return the result.

fun…


Before we learn about reified,

Generics in any language is the powerful features that allow us to define classes, methods and properties which are accessible using different data types while keeping a check of the compile-time type safety.

This post was originally posted at https://agrawalsuneet.github.io/blogs/reified-kotlin/ and reposted on Medium on 8th Mar 2021.

The best example for generics is Array or any List/Collection implementation.

package kotlin /** * Represents an array (specifically, a Java array when targeting the JVM platform). * Array instances can be created using the [arrayOf], [arrayOfNulls] and [emptyArray] * standard library functions. * See [Kotlin language documentation](https://kotlinlang.org/docs/reference/basic-types.html#arrays) * for more information…


Enums are special classes which limit the possible values of an object for that class. The possible values defined for that class are final or unchangeable.

The easiest way to define an enum is

enum class Direction {
EAST, WEST, NORTH, SOUTH
}

Here each enum constant is an object.

This post was originally posted at https://agrawalsuneet.github.io/blogs/kotlin-enum-classes/ and reposted on Medium on 16th Dec 2020.

For using these values

var direction : Direction = Direction.EAST

Base class of all Enum Classes

There is a base class for all enum classes which is defined in kotlin package.

/* * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language…

Adding a click event to a UIView is something which is required most of the times. For views like UIButton, we can simply connect an IBAction with the event type and detect the click events but sometimes we need it for Lable or even other views.

If you try to add an IBAction to your view, you won’t get Action as an option while connecting it with ViewController.

This post was originally posted at https://agrawalsuneet.github.io/blogs/uiview-clicklistener-swift/ and reposted on Medium on 14th Dec 2020.

The only possible way to add a click event on UIView is using UITapGestureRecognizer. You can either…


Variables, Objects and References, we frequently listen to these terms while development but usually gets confused between them.

This post was originally posted at https://agrawalsuneet.github.io/blogs/variable-vs-object-vs-reference/ and reposted on Medium on 4th Dec 2020.

Let’s try to understand a very basic definition along with an example for all three. The concept is similar in any object-oriented programming language but for reference, I’ll be using Java examples. Feel free to comment below if you need examples in any specific language.

Variables

Variables are named storage of any primitive data type.

Name storage means we (developers) define the name of the variable. Primitive data…


In the previous blogs, we learnt about how can we trigger native Android text, image or any other format file sharing in Unity App. A lot of you have asked me about how can we share some text directly to a WhatsApp contact.

If you have not read the previous medium posts, I would strongly recommend to read them first. You can read them on the links below.

This post was originally posted at https://agrawalsuneet.github.io/blogs/native-android-text-sharing-to-whatsapp-contact-in-unity/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store