Skip to content

Commit

Permalink
bug examples
Browse files Browse the repository at this point in the history
Signed-off-by: Norman Meier <[email protected]>
  • Loading branch information
n0izn0iz committed Aug 1, 2023
1 parent ebea17a commit 33259db
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 0 deletions.
22 changes: 22 additions & 0 deletions examples/gno.land/r/demo/bugs/bugmin/bugmin.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package bugmin

import (
"strconv"
"strings"
)

var slice = []string{"undead-element"}

func Pop() {
slice = slice[:len(slice)-1]
}

func Push() {
slice = append(slice, "new-element")
}

func Render(path string) string {
str := strings.Join(slice, ", ") + "\n\n"
str += "len: " + strconv.Itoa(len(slice)) + "\n\n"
return str
}
1 change: 1 addition & 0 deletions examples/gno.land/r/demo/bugs/bugmin/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module "gno.land/r/demo/bugs/bugmin"
1 change: 1 addition & 0 deletions examples/gno.land/r/demo/bugs/slice_splice/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module "gno.land/r/demo/bugs/slice_splice"
20 changes: 20 additions & 0 deletions examples/gno.land/r/demo/bugs/slice_splice/slice_splice.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package slice_splice

import (
"strings"
)

var slice = []string{}

func Push() {
slice = append(slice, "1", "2", "3", "4", "5", "6", "7", "8", "9", "10")
}

func Splice() []string {
slice = slice[4:5]
return slice
}

func Render(path string) string {
return strings.Join(slice, ",")
}
1 change: 1 addition & 0 deletions examples/gno.land/r/demo/bugs/two_slices_one_array/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module "gno.land/r/demo/bugs/two_slices_one_array"
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package two_slices_one_array

import (
"strings"
)

var (
slice = []string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}
sub1 []string = nil
sub2 []string = nil
)

func Split() {
sub1 = slice[0:5]
sub2 = slice[5:]
}

func Render(path string) string {
return "slice: " + strings.Join(slice, ",") + "\n\n" + "sub1: " + strings.Join(sub1, ",") + "\n\n" + "sub2: " + strings.Join(sub2, ",")
}

0 comments on commit 33259db

Please sign in to comment.