Syntax: fn type name

This commit is contained in:
2026-06-16 03:29:01 +02:00
parent eea72f5bb3
commit aadccb7f38
15 changed files with 9 additions and 842 deletions
-56
View File
@@ -1,56 +0,0 @@
pub module class_test;
pub class Animal<T> {
pub name String;
pub val T;
constructor() {
self.name = "Rex".to_string();
}
pub fn speak(*self) {
println!("Unknown");
}
pub fn test_speak(*self) {
self.speak();
}
pub fn static_method() {}
}
pub class Mammal<T> : Animal<T> {
constructor() {
super = Super::new();
}
pub fn args_test(*self, x i32, y *str) {}
pub fn returning<'a>(*self) *'a str {
"Mammal"
}
}
pub class Dog : Mammal<i32> {
constructor() {
super = Super::new();
}
pub override(Animal<i32>) fn speak(*self) {
println!("Woof!");
}
pub override fn returning(*self) *str {
"Dog"
}
}
pub fn run_tests() {
let dawg = Dog::new();
dawg.args_test(10, "hello");
dawg.test_speak();
println!("{}", dawg.returning());
}