layout: page title: “Kotlin interpreter in Apache Zeppelin” description: “Kotlin is a cross-platform, statically typed, general-purpose programming language with type inference.” group: interpreter

{% include JB/setup %}

Kotlin interpreter for Apache Zeppelin

Overview

Kotlin is a cross-platform, statically typed, general-purpose programming language with type inference. It is designed to interoperate fully with Java, and the JVM version of its standard library depends on the Java Class Library, but type inference allows its syntax to be more concise.

Configuration

Example

%kotlin 

fun square(n: Int): Int = n * n

Kotlin Context

Kotlin context is accessible via kc object bound to the interpreter. It holds vars and functions fields that return all user-defined variables and functions present in the interpreter. You can also print variables or functions by calling kc.showVars() or kc.showFunctions().

Example

fun square(n: Int): Int = n * n

val greeter = { s: String -> println("Hello $s!") }
val l = listOf("Drive", "to", "develop")

kc.showVars()
kc.showFunctions()

Output:

l: List<String> = [Drive, to, develop]
greeter: (String) -> Unit = (kotlin.String) -> kotlin.Unit
fun square(Int): Int