forked from gnolang/gno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Norman Meier <[email protected]>
- Loading branch information
Showing
6 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module "gno.land/r/demo/bugs/bugmin" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
20
examples/gno.land/r/demo/bugs/slice_splice/slice_splice.gno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, ",") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module "gno.land/r/demo/bugs/two_slices_one_array" |
20 changes: 20 additions & 0 deletions
20
examples/gno.land/r/demo/bugs/two_slices_one_array/two_slices_one_array.gno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, ",") | ||
} |