Browse Source

Fix firsword

content-update
Xavier Petit 4 years ago
parent
commit
135a631654
No known key found for this signature in database
GPG Key ID: CA3F2B17E25ABD26
  1. 5
      go/tests/prog/firstword_prog/main.go
  2. 4
      subjects/firstword/README.md

5
go/tests/prog/firstword_prog/main.go

@ -8,6 +8,9 @@ import (
func main() {
if len(os.Args) == 2 {
fmt.Println(strings.Split(strings.TrimSpace(os.Args[1]), " ")[0])
s := strings.Split(strings.TrimSpace(os.Args[1]), " ")[0]
if s != "" {
fmt.Println(s)
}
}
}

4
subjects/firstword/README.md

@ -2,9 +2,9 @@
### Instructions
Write a program that takes a `string` and displays its first word, followed by a newline (`'\n'`).
Write a program that takes an argument and displays its first word, followed by a newline (`'\n'`).
- A word is a section of `string` delimited by spaces or by the start/end of the `string`.
- A word is a sequence of characters delimited by spaces or by the start/end of the argument.
- The output will be followed by a newline (`'\n'`).

Loading…
Cancel
Save