rename strings
This commit is contained in:
26
examples/structs.bl
Normal file
26
examples/structs.bl
Normal file
@@ -0,0 +1,26 @@
|
||||
fn main(): i64 {
|
||||
let user = User{id: 4};
|
||||
return user.instance_method();
|
||||
}
|
||||
|
||||
type User struct {
|
||||
id: i64
|
||||
}
|
||||
|
||||
type TestTrait trait {
|
||||
fn class_method(id: i64): Self;
|
||||
fn instance_method(self: Self): i64;
|
||||
fn default_impl(self: Self): i64;
|
||||
}
|
||||
|
||||
impl TestTrait for User {
|
||||
fn class_method(id: i64): Self {
|
||||
return Self{id: id};
|
||||
}
|
||||
fn instance_method(self: Self): i64 {
|
||||
return self.id;
|
||||
}
|
||||
fn default_impl(self: Self): i64 {
|
||||
return self.instance_method();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user