github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/gnovm/tests/files/closure0.gno (about)

     1  package main
     2  
     3  type adder func(int, int) int
     4  
     5  func genAdd(k int) adder {
     6  	return func(i, j int) int {
     7  		return i + j + k
     8  	}
     9  }
    10  
    11  func main() {
    12  	f := genAdd(5)
    13  	println(f(3, 4))
    14  }
    15  
    16  // Output:
    17  // 12