Skip to content

Instantly share code, notes, and snippets.

View goindwalia's full-sized avatar

Gursimran Singh goindwalia

  • India
View GitHub Profile
$ docker build -t <name of your Kotlin application>:<version of application>
FROM maven:3-alpine
MAINTAINER XenonStack
# Creating Application Source Code Directory
RUN mkdir -p /usr/src/app
# Setting Home Directory for containers
WORKDIR /usr/src/app
fun(x: Int, y: int): Int {
return a + b
}
fun(x: Int, y: Int): Int = x + y
val sum: (Int, Int) -> Int = { x, y -> x + y }
fun alphaNum(func: () -> Unit) {}
fun main(args: Array<String>) {
val numbers = arrayListOf(15, -5, 11, -39)
val nonNegativeNumbers = numbers.filter { it >= 0 }
println(nonNegativeNumbers)
}
/* not explicitly defined */
fun main(args: Array<String>) {
val text = 10
println(text)
}
fun demo(x:Any){
if(x is String){
print(x.length) // x is automatically cast to string
}
}
val abc = mutableListOf(1, 2, 3)
abc.swap(0, 2)