fun main() {
val name = "Alice"
val age = 30
// Simple variable interpolation
println("Hello, $name!") // Hello, Alice!
// Expression interpolation with ${ ... }
println("$name is ${age * 12} months old") // Alice is 360 months old
// Access properties/methods directly
println("name has ${name.length} letters")
// Raw strings — no escape processing, can span multiple lines
val sql = """
SELECT id, name
FROM users
WHERE name = '$name'
ORDER BY created_at DESC
""".trimIndent()
println(sql)
// Inside raw strings, literal $ is "$" or just escape with \$
val price = """The price is ${'$'}9.99"""
println(price) // The price is $9.99
}
Create a free account and build your private vault. Share publicly whenever you want.