Resources

Introduction

Last week, we went over higher order functions in Kotlin. We learned how higher order functions can accept functions as parameters and are also able to return functions. This week, we will take a look at lambdas. Lambdas are another type of function and they are very popular in the functional programming world.



Logic & Data

Computer programs are made up of two parts: logic and data. Usually, logic is described in functions and data is passed to those functions. The functions do things with the data, and return a result. When we write a function we would typically create a named function. As we saw last week, this is a typical named function:

fun hello(name: String): String {
return "Hello, $name"
}

Then you can call this function:

fun main() {
println(hello("Matt"))
}

Which gives us the result:

Hello, Matt

Functions as Data

There is a concept in the functional programming world where functions are treated as data. Lambdas (functions as data) can do the same thing as named functions, but with lambdas, the content of a given function can be passed directly into other functions. A lambda can also be assigned to a variable as though it were just a value.

Lambda Syntax

Lambdas are similar to named functions but lambdas do not have a name and the lambda syntax looks a little different. Whereas a function in Kotlin would look like this:

fun hello() {
return "Hello World"
}

The lambda expression would look like this:

{ "Hello World" }

Here is an example with a parameter:

fun(name: String) {
return "Hello, ${name}"
}

The lambda version:

{ name: String -> "Hello, $name" }

You can call the lambda by passing the parameter to it in parentheses after the last curly brace:

{ name: String -> "Hello, $name" }("Matt")

It’s also possible to assign a lambda to a variable:

val hello = { name: String -> "Hello, $name" }

You can then call the variable the lambda has been assigned to, just as if it was a named function:

hello("Matt")

Lambdas provide us with a convenient way to pass logic into other functions without having to define that logic in a named function. This is very useful when processing lists or arrays of data. We’ll take a look at processing lists with lambdas in the next post!

Views: 163

Happy 10th year, JCertif!

Notes

Welcome to Codetown!

Codetown is a social network. It's got blogs, forums, groups, personal pages and more! You might think of Codetown as a funky camper van with lots of compartments for your stuff and a great multimedia system, too! Best of all, Codetown has room for all of your friends.

When you create a profile for yourself you get a personal page automatically. That's where you can be creative and do your own thing. People who want to get to know you will click on your name or picture and…
Continue

Created by Michael Levin Dec 18, 2008 at 6:56pm. Last updated by Michael Levin May 4, 2018.

Looking for Jobs or Staff?

Check out the Codetown Jobs group.

 

Enjoy the site? Support Codetown with your donation.



InfoQ Reading List

VoidZero’s Experimental Oxc Angular Compiler with Up to 20x Faster Build Performance

VoidZero has released an experimental Angular compiler in Rust, promising improved build performance compared to Angular CLI. Benchmarks indicate it is up to 6.4x faster than Angular CLI, especially for larger applications. Developed over two months with AI collaboration, it integrates with Vite and offers significant reductions in build time. The initiative is for research purposes only.

By Daniel Curtis

Microsoft Releases .NET 11 Preview 3 with Updates Across Runtime, SDK, MAUI, and ASP.NET Core

Microsoft has released .NET 11 Preview 3, the third preview of its upcoming Standard Term Support version due in November 2026. The update spans the runtime, SDK, libraries, ASP.NET Core, EF Core, and .NET MAUI, with Runtime Async leaving the preview-feature gate, new JIT optimizations, Zstandard compression in ASP.NET Core, and expanded MAUI Map controls.

By Almir Vuk

Presentation: Agents, Architecture, & Amnesia: Becoming AI-Native Without Losing Our Minds

Tracy Bannon shares a cautionary tale of "The Sorcerer’s Apprentice" to illustrate the risks of unbridled AI autonomy. She discusses the shift from bots to autonomous agents, explaining how reckless speed leads to "Architectural Amnesia." She provides a concrete framework for "Minimum Viable Governance," focusing on identity, delegation, and ADRs to manage debt at machine speed across the SDLC.

By Tracy Bannon

Sauce Labs Launches AI Agent to Automate Test Creation and Close the DevOps “Velocity Gap”

Sauce Labs has announced the general availability of Sauce AI for Test Authoring, an AI-driven agent designed to translate business intent directly into executable test suites, marking a shift toward what the company calls Intent-Driven Testing.

By Craig Risi

Mistral AI Introduces Workflows for Orchestrating Enterprise AI Processes

Mistral AI has launched Workflows, an orchestration layer for enterprise AI that is now in public preview. This release addresses a significant challenge as AI models and agents become more advanced, while reliably deploying them in production remains difficult due to a lack of infrastructure for coordination, monitoring, and recovery.

By Robert Krzaczyński

© 2026   Created by Michael Levin.   Powered by

Badges  |  Report an Issue  |  Terms of Service