Skip to content
skotch
...

Syntax

This page covers the Kotlin syntax that Skotch currently compiles.

fun add(a: Int, b: Int): Int {
return a + b
}
// Expression body shorthand
fun multiply(a: Int, b: Int): Int = a * b
val name = "Skotch" // immutable, type inferred
var count: Int = 0 // mutable, explicit type
fun Int.isEven(): Boolean = this % 2 == 0
fun main() {
println(4.isEven()) // true
}
fun main() {
fun helper(x: Int): Int = x * 2
println(helper(21)) // 42
}
val decimal = 42
val hex = 0xFF
val binary = 0b1010
val withSeparator = 1_000_000
val long = 100L
val regular = "hello\nworld"
val raw = """
no escape processing
preserves newlines
"""
val template = "value: $x"
val exprTemplate = "sum: ${a + b}"
val letter = 'A'
val newline = '\n'
val tab = '\t'
val yes = true
val no = false
CategoryOperators
Arithmetic+ - * / %
Comparison== != < > <= >=
Logical&& || !
Unary- (negation), ! (not)
Assignment= += -= *= /= %=
String concat+ (String + String, String + Int)
// Line comment
/* Block comment */

Semicolons are optional. Skotch uses newlines as statement terminators, consistent with standard Kotlin.