commit | d37365dd9093aefad36c14cc89c65c2c5d3c928e | [log] [tgz] |
---|---|---|
author | Joshua Mervine <joshua@mervine.net> | Tue Mar 10 22:25:29 2015 -0700 |
committer | Joshua Mervine <joshua@mervine.net> | Tue Mar 10 22:25:29 2015 -0700 |
tree | 8f4c98cf30e8a138b33ad1824145d011e4e7bd28 | |
parent | 28a0095a9739f9755bf46057c405738c9861b1b5 [diff] [blame] |
Adding "Shift" and "Unshift" examples.
diff --git a/SliceTricks.md b/SliceTricks.md index 68d90a2..59118f4 100644 --- a/SliceTricks.md +++ b/SliceTricks.md
@@ -89,6 +89,17 @@ a = append(a, x) ``` +**Shift** +``` +x, a := a[0], a[1:] +``` + +**Unshift** +``` +// use appropriate type +a = append([]string{x}, a...) +``` + ## Additional Tricks ### Filtering without allocating