Skip to content

Commit 7bd001e

Browse files
authored
improve Reorder example (#32)
1 parent eb16c23 commit 7bd001e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

example_provider_test.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -114,24 +114,30 @@ func ExampleNonFinal() {
114114
// This demonstrates how it to have a default that gets overridden by
115115
// by later inputs.
116116
func ExampleReorder() {
117+
type string2 string
117118
seq1 := nject.Sequence("example",
118119
nject.Shun(func() string {
119120
fmt.Println("fallback default included")
120121
return "fallback default"
121122
}),
123+
func(s string) string2 {
124+
return "<" + string2(s) + ">"
125+
},
122126
)
123127
seq2 := nject.Sequence("later inputs",
128+
// for this to work, it must be reordered to be in front
129+
// of the string->string2 provider
124130
nject.Reorder(func() string {
125131
return "override value"
126132
}),
127133
)
128134
fmt.Println(nject.Run("combination",
129135
seq1,
130136
seq2,
131-
func(s string) {
137+
func(s string2) {
132138
fmt.Println(s)
133139
},
134140
))
135-
// Output: override value
141+
// Output: <override value>
136142
// <nil>
137143
}

0 commit comments

Comments
 (0)