Conlang/sample-code/match_test.cl
John 7ba808594c cl-ast: Cleanup
- Function bind is now one Pattern
- TyRef now allows &Ty (i.e. &[i32], &(char, bool)
- Range patterns (they cannot bind, only check whether a value is in range
- ArrayRep repeat has been reverted to usize, for now, until early consteval is implemented.
2025-04-21 04:17:45 -04:00

19 lines
506 B
Common Lisp

//! This is a Conlang library demonstrating `match`
struct Student {
name: str,
age: i32,
}
fn Student(name: str, age: i32) -> Student {
Student { name, age }
}
fn match_test(student: Student) {
match student {
Student { name: "shark", age } => println("Found a shark of ", age, " year(s)"),
Student { name, age: 22 } => println("Found a 22-year-old named ", name),
Student { name, age } => println("Found someone named ", name, " of ", age, " year(s)"),
}
}