0
0
Kotlinprogramming~15 mins

It keyword for single parameter in Kotlin - Mini Project: Build & Apply

Choose your learning style9 modes available
Using the It Keyword for Single Parameter in Kotlin
📖 Scenario: You are working on a simple Kotlin program that processes a list of names. You want to transform each name to uppercase using a concise way to handle single parameters in lambda expressions.
🎯 Goal: Learn how to use the it keyword in Kotlin lambda expressions when there is only one parameter.
📋 What You'll Learn
Create a list of names with exact values
Create a lambda expression using the it keyword to convert names to uppercase
Store the transformed names in a new list
Print the new list
💡 Why This Matters
🌍 Real World
Using the <code>it</code> keyword helps write shorter and clearer code when working with collections, such as lists of names, products, or messages.
💼 Career
Many Kotlin jobs require working with collections and lambdas. Knowing how to use <code>it</code> makes your code concise and easier to read, which is valued in professional Kotlin development.
Progress0 / 4 steps
1
Create a list of names
Create a list called names with these exact values: "alice", "bob", "charlie"
Kotlin
Need a hint?

Use listOf to create a list with the given strings.

2
Create a lambda expression using the it keyword
Create a new list called upperNames by calling names.map and use a lambda expression with the it keyword to convert each name to uppercase using it.uppercase()
Kotlin
Need a hint?

Use map with a lambda that uses it to refer to each element.

3
Print the transformed list
Print the upperNames list using println(upperNames)
Kotlin
Need a hint?

Use println to display the list.

4
Use the it keyword in a filter lambda
Create a new list called filteredNames by calling names.filter and use a lambda with the it keyword to keep only names that start with the letter 'a' using it.startsWith('a'). Then print filteredNames using println(filteredNames)
Kotlin
Need a hint?

Use filter with a lambda using it to check the first letter.