Logo

Programming-Idioms

History of Idiom 22 > diff from v52 to v53

Edit summary for version 53 by programming-idioms.org:
[Go] Var names s and i in demo

Version 52

2016-11-13, 22:34:44

Version 53

2016-11-13, 22:37:04

Idiom #22 Convert string to integer

Extract integer value i from its string representation s (in radix 10)

Illustration

Idiom #22 Convert string to integer

Extract integer value i from its string representation s (in radix 10)

Illustration
Extra Keywords
int base
Extra Keywords
int base
Imports
import "strconv"
Imports
import "strconv"
Code
i, err  := strconv.Atoi(s) 
Code
i, err  := strconv.Atoi(s) 
Comments bubble
Atoi(s) is shorthand for ParseInt(s, 10, 0). It yields type int.
Comments bubble
Atoi(s) is shorthand for ParseInt(s, 10, 0). It yields type int.
Doc URL
http://golang.org/pkg/strconv/#Atoi
Doc URL
http://golang.org/pkg/strconv/#Atoi
Demo URL
http://play.golang.org/p/VXjGHZbj6J
Demo URL
https://play.golang.org/p/YjYPEj10ms