From 29c6d8b3e48a57fbea8f74497926533b41a87810 Mon Sep 17 00:00:00 2001 From: David Eisinger Date: Sun, 16 Jul 2023 22:01:04 -0400 Subject: [PATCH] [go] first-class functions, slice/append --- content/notes/golang/index.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/content/notes/golang/index.md b/content/notes/golang/index.md index f84d7ce..7262404 100644 --- a/content/notes/golang/index.md +++ b/content/notes/golang/index.md @@ -126,6 +126,13 @@ I find [Go][1] really compelling, even though it's not super applicable to my jo > A two-value assignment tests for the existence of a key: `i, ok := m["route"]` +* First-class functions + * Go supports first-class functions (functions as arguments and return values of other functions) + * Go has closures (so variables defined inside a function that returns a function get closed over) + * Go has anonymous functions (`func` w/o name) +* Slices + * Use `append` to add to a slice; this creates a new slice, so you have to capture the return value (`s = append(s, 100)`) + [17]: https://stackoverflow.com/a/40951013 [18]: https://go.dev/doc/effective_go#named-results [19]: https://exercism.org/tracks/go/concepts/errors