mirror of https://github.com/01-edu/public.git
Browse Source
* DEV-3206 add(docs):StringTobool readme * DEV-3206 fix(docs):replace the example * Update README.md * docs(stringtobool): fix subject - upgraded instructions - fix 'expected function' - add missing import 'piscine' - fix white-spaces and indentation * docs(stringtobool): fix typo --------- Co-authored-by: Tiago Collot <collot.tiago1@gmail.com> Co-authored-by: Michele Sessa <mikysett@gmail.com>pull/1513/head
Hamza elkhatri
1 year ago
committed by
GitHub
1 changed files with 46 additions and 0 deletions
@ -0,0 +1,46 @@ |
|||||||
|
## stringtobool |
||||||
|
|
||||||
|
### Instructions |
||||||
|
|
||||||
|
Write a function that takes a `string` as an argument and returns a `boolean`. |
||||||
|
|
||||||
|
- If the `string` equals `True`, `T` or `t` return `true`, otherwise return `false`. |
||||||
|
|
||||||
|
|
||||||
|
### Expected function |
||||||
|
|
||||||
|
```go |
||||||
|
func StringToBool(s string) bool { |
||||||
|
|
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
### Usage |
||||||
|
|
||||||
|
Here is a possible program to test your function: |
||||||
|
|
||||||
|
```go |
||||||
|
package main |
||||||
|
|
||||||
|
import ( |
||||||
|
"fmt" |
||||||
|
"piscine" |
||||||
|
) |
||||||
|
|
||||||
|
func main() { |
||||||
|
fmt.Println(piscine.StringToBool("True")) |
||||||
|
fmt.Println(piscine.StringToBool("T")) |
||||||
|
fmt.Println(piscine.StringToBool("False")) |
||||||
|
fmt.Println(piscine.StringToBool("TTFF")) |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
And its output: |
||||||
|
|
||||||
|
```console |
||||||
|
$ go run . |
||||||
|
true |
||||||
|
true |
||||||
|
false |
||||||
|
false |
||||||
|
``` |
Loading…
Reference in new issue