Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -0,0 +1,11 @@
import (
"image"
"image/gif"
"io/ioutil"
"strings"
"unicode"
)
func f() (int, float64) { return 0, 0 }
func g(int, float64) int { return 0 }
func h(string, ...int) {}

View file

@ -0,0 +1,9 @@
f()
g(1, 2.0)
// If f() is defined to return exactly the number and type of
// arguments that g() accepts than they can be used in place:
g(f())
// But only without other arguments, this won't compile:
//h("fail", f())
// But this will:
g(g(1, 2.0), 3.0)

View file

@ -0,0 +1,8 @@
h("ex1")
h("ex2", 1, 2)
h("ex3", 1, 2, 3, 4)
// such functions can also be called by expanding a slice:
list := []int{1,2,3,4}
h("ex4", list...)
// but again, not mixed with other arguments, this won't compile:
//h("fail", 2, list...)

View file

@ -0,0 +1 @@
gif.Encode(ioutil.Discard, image.Black, &gif.Options{NumColors: 16})

View file

@ -0,0 +1 @@
if 2*g(1, 3.0)+4 > 0 {}

View file

@ -0,0 +1,9 @@
fn := func(r rune) rune {
if unicode.IsSpace(r) {
return -1
}
return r
}
strings.Map(fn, "Spaces removed")
strings.Map(unicode.ToLower, "Test")
strings.Map(func(r rune) rune { return r + 1 }, "shift")

View file

@ -0,0 +1,4 @@
a, b := f() // multivalue return
_, c := f() // only some of a multivalue return
d := g(a, c) // single return value
e, i := g(d, b), g(d, 2) // multiple assignment

View file

@ -0,0 +1,2 @@
list = append(list, a, d, e, i)
i = len(list)