THE BEST NEWSLETTER ANYWHERE
Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.
This tutorials explains about convert String
to int
and int
to string
in Nim language with examples.
parseInt
in strutils
module convert given string to integer. It throws an ValueError
if string is invalid number.
Here is an example
import strutils
const value = parseInt("12")
echo typeof(value) # int
echo value # 12
Multiple ways we can convert int to string in nim.
$
is a toString()
operator that converts any type to String.
Here is an example
import strutils
const number=11
let str = $number
echo typeof(str) # string
echo str # 11
strutils intToStr
operatorstrutils intToStr
function convert int to string
Here is an example
import strutils
const number=11
let str = intToStr(number)
echo typeof(str) # string
echo str # 11
🧮 Tags
Recent posts
Julia examples - Variable Type Nim example - Convert String to/from the Int How to get length of an array and sequence in Nim? Nim environment variables - read, set, delete, exists, and iterate examples? How to convert from single character to/from string in Nim?Related posts