Quick Answer

Referencing a function without invoking it

Understanding the Issue

This error occurs when you reference a function but forget to call it (with parentheses), or when using incorrect syntax for function types.

The Problem

This code demonstrates the issue:

Kotlin Error
// Problem: Missing invocation
fun greet() = println("Hello")
val result = greet // Error

The Solution

Here's the corrected code:

Kotlin Fixed
// Solution 1: Call the function
val result = greet() // Correct

// Solution 2: Get function reference
val greetFunc = ::greet

// Solution 3: Lambda syntax
val greetLambda = { greet() }

Key Takeaways

Ensure functions are properly invoked with () or referenced with :: when needed.