Skip to content

Instantly share code, notes, and snippets.

View passiondroid's full-sized avatar
🏠
Working from home

Arif Khan passiondroid

🏠
Working from home
View GitHub Profile
@antonyharfield
antonyharfield / RailwayOP-CompleteExample.kt
Created April 29, 2019 17:51
Railway Oriented Programming in Kotlin (as described here)
// Result is a superpowered enum that can be Success or Failure
// and the basis for a railway junction
sealed class Result<T>
data class Success<T>(val value: T): Result<T>()
data class Failure<T>(val errorMessage: String): Result<T>()
// Composition: apply a function f to Success results
infix fun <T,U> Result<T>.then(f: (T) -> Result<U>) =
when (this) {
is Success -> f(this.value)
@dodyg
dodyg / gist:5823184
Last active March 29, 2024 03:59
Kotlin Programming Language Cheat Sheet Part 1

#Intro

Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3

Kotlin project website is at kotlin.jetbrains.org.

All the codes here can be copied and run on Kotlin online editor.

Let's get started.