interfaces.gno

0.61 Kb ยท 30 lines
 1package tests
 2
 3import (
 4	"strconv"
 5)
 6
 7type Stringer interface {
 8	String() string
 9}
10
11var stringers []Stringer
12
13func AddStringer(str Stringer) {
14	crossing()
15
16	// NOTE: this is ridiculous, a slice that will become too long
17	// eventually.  Don't do this in production programs; use
18	// gno.land/p/demo/avl or similar structures.
19	stringers = append(stringers, str)
20}
21
22func Render(path string) string {
23	res := ""
24	// NOTE: like the function above, this function too will eventually
25	// become too expensive to call.
26	for i, stringer := range stringers {
27		res += strconv.Itoa(i) + ": " + stringer.String() + "\n"
28	}
29	return res
30}