Friday, May 6, 2011

Ruby Difference Between Integer Methods

What is the difference between

10.6.to_i

and

10.6.to_int ?

From stackoverflow
  • There is no difference. They are synonymous.

    Andrew Grimm : to_i and to_int may give the same result for 10.6, but "42".to_i works, whereas "42".to_int raises a NoMethodError, for reasons given in kgiannakakis's link.
  • Read more about it here.

0 comments:

Post a Comment