Files use .rex, the command is rex, and the crate, runtime prefixes, docs, editor files and examples all use the new name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
24 lines
408 B
Rexx
24 lines
408 B
Rexx
// Enums with data, generics, interfaces.
|
|
enum Shape {
|
|
Circle(r: f64)
|
|
Rect(w, h: f64)
|
|
}
|
|
|
|
func area(s: Shape): f64 {
|
|
return match s {
|
|
Circle(r) => 3.14159 * r * r
|
|
Rect(w, h) => w * h
|
|
}
|
|
}
|
|
|
|
interface Drawable { draw() }
|
|
|
|
func draw_all[T: Drawable](items: []T) {
|
|
for item in items { item.draw() }
|
|
}
|
|
|
|
func max[T: Ordered](a, b: T): T {
|
|
if a > b { return a }
|
|
return b
|
|
}
|