Skip to content

Commit

Permalink
Fix example
Browse files Browse the repository at this point in the history
  • Loading branch information
dave committed Dec 18, 2021
1 parent 60f2696 commit 4ccd8bb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion README.md
Expand Up @@ -685,7 +685,12 @@ Union renders a pipe separated list. Use for union type constraints.
### Examples

```go
c := Func().Id("Keys").Types(Id("K").Comparable(), Id("V").Any()).Params(Id("m").Map(Id("K")).Id("V")).Index().Id("K").Block()
c := Func().Id("Keys").Types(
Id("K").Comparable(),
Id("V").Any(),
).Params(
Id("m").Map(Id("K")).Id("V"),
).Index().Id("K").Block()
fmt.Printf("%#v", c)
// Output:
// func Keys[K comparable, V any](m map[K]V) []K {}
Expand Down
7 changes: 6 additions & 1 deletion jen/examples_test.go
Expand Up @@ -8,7 +8,12 @@ import (
)

func ExampleGenericsTypesDefinition() {
c := Func().Id("Keys").Types(Id("K").Comparable(), Id("V").Any()).Params(Id("m").Map(Id("K")).Id("V")).Index().Id("K").Block()
c := Func().Id("Keys").Types(
Id("K").Comparable(),
Id("V").Any(),
).Params(
Id("m").Map(Id("K")).Id("V"),
).Index().Id("K").Block()
fmt.Printf("%#v", c)
// Output:
// func Keys[K comparable, V any](m map[K]V) []K {}
Expand Down

0 comments on commit 4ccd8bb

Please sign in to comment.