Array vs Iterable

In Kotlin, the Collections Related Class includes :

So what are their differences ? I will spend approximately 2–3 articles on this topic, but in this article, I want to focus on the most asked questions for beginners.

1. What are the differences between Array and List ?
2. What are the differences between Array and ArrayList ?

In order to answer these questions, we will take a look at how they are defined.

Array

public class Array<T> {
public inline constructor(size: Int, init: (Int) -> T)
public val size: Int…


Apparently, there are 4 ways in total

In Journey with Kotlin 002, we talked about how to create a button and how to set an OnClickListener for it. Today, I want to show you other ways to create an OnClickListener.

The button we want to apply the OnClickListener is called rollButton .

As mentioned in Journey with Kotlin 002, we can set the button’s OnClickListener by :

Method 1 — Anonymous Function

Method 2 — Interface Type

Instead of using a member class, we can create a variable with OnClickListener type and simply use it…


Understand how Activity works

In this article, I want to talk about how Activity works while building a simply Dice Roller app, that generates a random number between 1…6 whenever the button is pressed.

To begin, let’s set up an app with Empty Activity called Dice Roller.

Next, we are going to take a look at MainActivity.

MainActivity


An introduction to Android Studio

This article assumed that you have successfully installed Android Studio and is ready to create your very first app, the classic Hello World.

Without any ado, let’s get started.

Creating a Project

Opening Android Studio

When you first open Android Studio, you will be prompted to select what you want to do :


Button in SwiftUI is … very interesting

Button

A Button is a control that performs an action when triggered.

Although the definition for a button is very straight forward, it is a whole other story when examining its initialize methods …


As amazing as WWDC 2019 showed us about SwiftUI, I can’t seem to wrap my head around how SwiftUI works.

In order to clear up my mind, I have decided to take a deep look on what exactly is a View and how do we modify it.

View

In SwiftUI, when we are creating an interface, we need to wrap its content in the body within a View. So the millionaire question is:

What is a View ?


An introduction to Struct

What is a Struct ?

A Struct is a model, which is a container for storing data and defining model behavior. It is very similar to a Class. The main difference between the two is that a Struct passes by Value whereas a Class passes by Reference.

So whenever you are passing a struct as a parameter, the function will hold a Copy of the struct. On the other hand, when a class is passed in as a parameter, the function will get hold of a Reference of its Memory Position.

I will discuss more on the differences between the two and how to choose…


Another way to define a function

What is a Closure ?

In Swift, a Closure is basically a function that is defined as a variable. In Objective C, we called it a Block.

The general form of a closure looks like this :

var closureName : (InputType) -> (ReturnType) = { parameterName in
//Statements
return ReturnType
}

Here is an example :


Swift 100 days Challenge continues (technically speaking 100 article challenge XD)

Today, I want to briefly talk about Functions and Error Handling.

What is a Function ?

Here is a picture that worth a thousand words.


Which one to use? It depends…

In Swift, there are two Error Handling Patterns, including:

do {
try functionThatThrowsError()
} catch ERROR_TYPE {
//Implementation
}

So what are the differences?

In order to get to answer this question, let me show you an example.

Let’s say we have a Car, and we need to decide whether it has enough fuel and if the engine is overheated. These…

Jimmy Liu

App Developer who enjoy learning from the ground up.

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