[RUBY] to_i method

to_i method

** A method that a string has. It converts a character string to a number. ** ** By the way, the meaning of i in to_i is "integer". See the example below.

[Example] irb


#To the string "30"_Execute with i method
irb(main):001:0> "30".to_i
=> 30

If it is a non-numeric string, it will be converted to the number 0.

Let's run the following code in irb

Let's try the to_i method.

irb


# to_Convert a string to a number with i
irb(main):001:0> "100".to_i + 400
=> 500

Summary

** The to_i method is a method that converts a character string into a number. ** **

that's all.

Recommended Posts

to_i method
Method
Java method
java (method)
getRequestDispatcher () method
merge method
Map method
include method
Abstract method
initialize method
List method
puts method
Java method
Class method
save! method
getParameter method
[Java] method
private method
rails method
[Java] method
Ruby to_s method
Screen transition method
Binary search binary search method
Method to search
Factory Method Pattern
Exception switching method
RxSwift method chain
Rails delegate method
scan method problem
Java8 method reference
[Ruby] slice method
[Ruby] end_with? method
[Ruby] Method memorandum
[HTTP method PATCH]
About the method
[Java] forEach method
[Practice] Map method
[Servlet] Basic method
variable and method
Binary search method
Template Method pattern
Template Method Pattern
0-filled (non-zero) method
JavaSilver11 study method
keycloak test-skip method
Factory Method pattern
[Ruby] initialize method
Ruby build method
undefined method `** _ path'error
java8 method reference
[Java] Random method
Ruby accessor method
[Java] split method
ruby map method