mirror of
https://github.com/bearlanguageorg/bear.git
synced 2026-08-26 15:37:18 +00:00
Production pass: floats, GC, type checking, and tooling
Adds floats, bitwise ops, UTF-8 strings with methods, try/catch, closures, generics validation, a compile-time type checker, a mark-and-sweep GC, source-level debug info, constant folding, and the repl/fmt/package-manager commands. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
// string interpolation: embed expressions inside "..." with ${}
|
||||
|
||||
fn main() {
|
||||
let name = "alice"
|
||||
let age = 30
|
||||
|
||||
// simple variable interpolation
|
||||
println("hello ${name}!")
|
||||
|
||||
// multiple interpolations
|
||||
println("${name} is ${age} years old")
|
||||
|
||||
// expression inside interpolation
|
||||
println("${name} will be ${age + 1} next year")
|
||||
|
||||
// interpolation with function calls
|
||||
let nums = [10, 20, 30]
|
||||
println("first element: ${nums[0]}")
|
||||
|
||||
// string concatenation with interpolation
|
||||
let greeting = "hi"
|
||||
println("${greeting}, ${name}! age=${age}")
|
||||
|
||||
// no interpolation (regular string)
|
||||
println("no interpolation here")
|
||||
|
||||
// empty interpolation adjacent to text
|
||||
let x = 42
|
||||
println("value is ${x}")
|
||||
|
||||
// arithmetic in interpolation
|
||||
println("double age: ${age * 2}")
|
||||
}
|
||||
Reference in New Issue
Block a user