Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how convert string to int in ruby

I obtain a string after use number = sep[1].scan(/\w+/) but later I need to compare number with other number. I known when I use sep[1].scan(/\w+/) I discard other symbols but how convert my string number into a real integer?

like image 983
anonimo342 Avatar asked Aug 31 '25 20:08

anonimo342


1 Answers

The solution for this problem is: with regular expression; number is an array with length 1 so I need to convert number[0] to array, like this: num_integer =number[0].to_i

like image 111
anonimo342 Avatar answered Sep 03 '25 17:09

anonimo342