Skip to content

Casting a variable as the correct type when it is read in as a string #3100

Discussion options

You must be logged in to vote

You could use the std lib's float module! Just add import gleam/float then call float.parse("123.4"). You'll then have to handle the result type, I recommend reading that section of the tour and looking at the std lib result module on hex docs if you're not familiar :) you can use the parse function from the int std lib module as well

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Dan-C-Reed
Comment options

Answer selected by Dan-C-Reed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants