Skip to content
skotch
...

Types

TypeDescriptionLiteral examples
Int32-bit signed integer42, 0xFF, 0b1010, 1_000
Long64-bit signed integer100L, 0xFFL, 9999999999L
Double64-bit floating-point3.14, 2.5e10, 1.0f, -0.5
StringUTF-8 string"hello", """raw""", "$x"
BooleanTrue or falsetrue, false
CharSingle character'A', '\n'
UnitNo meaningful valueImplicit void return
AnyTop type (supertype of all types)
nullNull referencenull

Skotch infers types from literal initializers:

val x = 42 // Int
val pi = 3.14 // Double
val s = "hello" // String
val b = true // Boolean
val n = null // null

Explicit type annotations are also supported:

val x: Int = 42
val s: String = "hello"

Double supports all arithmetic operators, and mixed Int/Double arithmetic promotes to Double:

fun main() {
val a = 3.0
val b = 2.0
println(a + b) // 5.0
println(a * b) // 6.0
println(a / b) // 1.5
println(-2.5) // -2.5
println(1.0e2) // 100.0
}

Function parameters require explicit types. Return types can be inferred for expression-body functions.

fun add(a: Int, b: Int) = a + b // return type Int inferred
fun greet(name: String): String { // explicit return type
return "Hello, $name"
}
FeatureStatus
Nullable operators (?., ?:, !!)Implemented — safe calls, elvis, non-null assertion
Type checks (is/!is)Implemented — emits instanceof with JVM type descriptors
Smart castsImplemented — when/if branch narrowing with checkcast + unbox for primitives
Type casts (as/as?)Parsed; safe cast (as?) returns null on failure
Generics (T, List<Int>)Implemented — type parameters, bounds, variance (in/out), star projection, reified
NothingImplemented — bottom type, assignable to all types
Type aliasesImplemented — typealias erased to underlying type
Char typeImplemented — Ty::Char with CharLit token, println('K') prints K, s[i] returns Char