Converting strings to other datatypes in Red

93 Views Asked by At

What is the recommended way to convert a string to an integer in Red?

One way I found is:

load "123"
== 123

Is load the best way of getting an integer from a string in Red?

Is there any danger in using load in this way specifically if the string is from an unvalidated source?

1

There are 1 best solutions below

1
On BEST ANSWER

Currently, that is the only way, as to action has not been implemented yet. It is safe using load, as it does not do any kind of evaluation and the construction syntax support is very basic (covering just none and logic values).

EDIT: to action is now available from v0.6.2 on, so to-integer "123" can be used too.