Skip to content

Commit

Permalink
example: update interface passed as param #22
Browse files Browse the repository at this point in the history
  • Loading branch information
douyixuan committed Aug 21, 2024
1 parent 0fa7ce2 commit 2f9f826
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions tests/examples/interface.cell
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,38 @@ import (
"errors"
"debug"
)

type Buffer table {
start uint64
end uint64
type Demo table {
start uint32
end uint32
}
func (b *Buffer) Start() (n uint64, err error) {
func (b *Demo) st() (n uint32, err error) {
return b.start, errors.None()
}
func (b *Demo) ed() uint32 {
return b.end
}
func (b *Demo) reset() {
b.start = 0
b.end = 0
}
type Range interface {
st() (uint32, error)
ed() uint32
reset()
}
func foo(b Range) {
n, err := b.st()
debug.Printf("%s", err.Error())
end := b.ed()
debug.Printf("%d", end)
b.reset()
}
func main() {
b := Buffer {
start: 100
end: 200
b := Demo {
start: uint32(1),
end: uint32(3),
}
n, _ := b.Start()
debug.Printf("%d", n)
foo(b)
debug.Printf("reset%d%d", b.start, b.end)
return 0
}

0 comments on commit 2f9f826

Please sign in to comment.