Skip to content

Commit

Permalink
in the hello example, reorder spanish and french and use variables in…
Browse files Browse the repository at this point in the history
… switch statement (#758)
  • Loading branch information
dario-piotrowicz authored May 6, 2024
1 parent 1c55629 commit db59555
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions hello-world.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,10 @@ func Hello(name string, language string) string {
prefix := englishHelloPrefix

switch language {
case "French":
prefix = frenchHelloPrefix
case "Spanish":
case spanish:
prefix = spanishHelloPrefix
case french:
prefix = frenchHelloPrefix
}

return prefix + name
Expand All @@ -481,8 +481,8 @@ You could argue that maybe our function is getting a little big. The simplest re
```go

const (
french = "French"
spanish = "Spanish"
french = "French"

englishHelloPrefix = "Hello, "
spanishHelloPrefix = "Hola, "
Expand Down
4 changes: 2 additions & 2 deletions hello-world/v7/hello.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ func Hello(name string, language string) string {
prefix := englishHelloPrefix

switch language {
case french:
prefix = frenchHelloPrefix
case spanish:
prefix = spanishHelloPrefix
case french:
prefix = frenchHelloPrefix
}

return prefix + name
Expand Down

0 comments on commit db59555

Please sign in to comment.