Golang, Go : convert string to float number -


http://play.golang.org/p/7kr2uzlv5-

this playground link. have array of numbers in string. tried convert them float number not give me anything. wrong it?

var numbers []float64  _, elem := range str_numbers {     i, err := strconv.parsefloat(elem, 64)     if err != nil {         numbers = append(numbers, i)     } } fmt.println(numbers)         // gives me nothing  [] 

change

if err != nil { 

to

if err == nil { 

(you may doing already, unit testing great way catch bugs this.)


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -