I want to convert an hex string value in a variable to int.
This works for a literal: "#{0xFF}".to_i
But with a var...?
Not working test (interpolation error):
_myvar = "FF"
"#{0x_myvar}".to_i
Why not check the API documentation for String
"FF".to_i(16)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With