Syntax: fn type name
This commit is contained in:
@@ -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());
|
||||
}
|
||||
Reference in New Issue
Block a user