This commit is contained in:
parent
db3a3e29eb
commit
42fa039daf
11 changed files with 522 additions and 138 deletions
29
records.ang
Normal file
29
records.ang
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
type User = (
|
||||
id: int,
|
||||
name: str,
|
||||
)
|
||||
|
||||
|
||||
user := {
|
||||
user_id := 0
|
||||
all_users := []User
|
||||
|
||||
(
|
||||
get_all: fn() -> [User] { all_users },
|
||||
new: fn(name: str) -> User {
|
||||
data := (id: { user_id = user_id + 1 }, name:)
|
||||
all_users.append(data)
|
||||
data
|
||||
},
|
||||
fmt: fn(user: User) -> str {
|
||||
user.name + "(" + str(user.id) + ")"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
abe := user.new("abe")
|
||||
lincoln := user.new("lincoln")
|
||||
|
||||
println(abe)
|
||||
println(lincoln)
|
||||
Loading…
Add table
Add a link
Reference in a new issue