Multiline strings with trimIndent
📖 Scenario: You are creating a simple Kotlin program to display a formatted message using multiline strings. Multiline strings help keep text readable and maintain the intended layout.
🎯 Goal: Build a Kotlin program that uses a multiline string with trimIndent() to remove extra indentation and print a clean, formatted message.
📋 What You'll Learn
Create a multiline string variable with indented text
Use
trimIndent() to remove common leading whitespacePrint the cleaned multiline string
💡 Why This Matters
🌍 Real World
Multiline strings with trimIndent are useful for writing formatted text blocks like messages, SQL queries, or JSON in Kotlin code without extra spaces.
💼 Career
Understanding multiline strings and trimming indentation helps write cleaner, more readable Kotlin code, a skill valuable for Android and backend Kotlin developers.
Progress0 / 4 steps