-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
Hi Yuuta,
In section "Functions As Data" you wrote the code below. Since activity is a slice and not a map you should refrain from using the word variable name "key", instead use variable name "index", since keys are associated with maps not slices or arrays.
Changing the name will make your code much easier to read and understand.
You wrote:
func compose(p phrases, a []activity) (func()){
return func(){
for key, value := range a{
fmt.Print(p[value])
if key == len(a)-1{
fmt.Println(".")
} else {
fmt.Print(" and ")
}
}
}
}
Should be corrected in following manner (see use of variable name "index" in place of "key")
func compose(p phrases, a []activity) (func()){
return func(){
for index, value := range a{
fmt.Print(p[value])
if index == len(a)-1{
fmt.Println(".")
} else {
fmt.Print(" and ")
}
}
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels