Défi : Révision des Concepts de Fonctions
Tâche
- Terminez le code pour le deuxième paramètre de la fonction
operate
, qui est censé accepter la fonctioncapitalize
; - Révisez le code et fournissez des arguments appropriés dans l'appel de la fonction
operate
dans la fonctionmain()
; - Enregistrez les valeurs retournées par l'appel de la fonction
operate
dans les variablesoriginal
etupdated
.
index.go
1234567891011121314151617181920212223package main import "fmt" // `ToLower()` and `ToUpper()` functions are imported from the `strings` module import "strings" func capitalize(str string) string { return strings.ToUpper(str) } func operate(str string, operation ___) (string, string) { return str, operation(str) } func main() { inputString := "Hello World" var original string var updated string ___ = operate(___) fmt.Println(original, updated) }
Tout était clair ?
Merci pour vos commentaires !
Section 4. Chapitre 7
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion
Suggested prompts:
Can you explain how the operate function works?
What does the capitalize function do in this context?
Can you show the output of the main function?
Awesome!
Completion rate improved to 1.96
Défi : Révision des Concepts de Fonctions
Glissez pour afficher le menu
Tâche
- Terminez le code pour le deuxième paramètre de la fonction
operate
, qui est censé accepter la fonctioncapitalize
; - Révisez le code et fournissez des arguments appropriés dans l'appel de la fonction
operate
dans la fonctionmain()
; - Enregistrez les valeurs retournées par l'appel de la fonction
operate
dans les variablesoriginal
etupdated
.
index.go
1234567891011121314151617181920212223package main import "fmt" // `ToLower()` and `ToUpper()` functions are imported from the `strings` module import "strings" func capitalize(str string) string { return strings.ToUpper(str) } func operate(str string, operation ___) (string, string) { return str, operation(str) } func main() { inputString := "Hello World" var original string var updated string ___ = operate(___) fmt.Println(original, updated) }
Tout était clair ?
Merci pour vos commentaires !
Section 4. Chapitre 7