## basicatoi2
### Instructions
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
- Write a function that simulates the behaviour of the `Atoi` function in Go. `Atoi` transforms a number defined as a `string` in a number defined as an `int` .
- Atoi returns `0` if the `string` is not considered as a valid number. For this exercise **non-valid `string` chains will be tested** . Some will contain non-digits characters.
- For this exercise the handling of the signs `+` or `-` does not have to be taken into account.
- This function will **only** have to return the `int` . For this exercise the `error` return of atoi is not required.
### Expected function
```go
func BasicAtoi2(s string) int {
}
```
### Usage
Here is a possible program to test your function :
```go
package main
import (
"fmt"
piscine ".."
)
func main() {
fmt.Println(piscine.BasicAtoi2("12345"))
fmt.Println(piscine.BasicAtoi2("0000000012345"))
fmt.Println(piscine.BasicAtoi2("012 345"))
fmt.Println(piscine.BasicAtoi2("Hello World!"))
}
```
And its output :
```console
student@ubuntu:~/basicatoi2/test$ go build
student@ubuntu:~/basicatoi2/test$ ./test
12345
12345
0
0
student@ubuntu:~/basicatoi2/test$
```