Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6154707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:18:25+00:00 2026-05-23T20:18:25+00:00

I use String.to_int, and some time i get errors, for example when the string

  • 0

I use String.to_int, and some time i get errors, for example when the string is not a representation of an int. I would like to catch these errors, or test parameter before to use the function. Some ideas ?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:18:26+00:00Added an answer on May 23, 2026 at 8:18 pm

    Hmm, one could argue that it would have been better if String.to_int from the stdlib returned an optional integer (none indicating an error).

    However, in Opa most parsing is done using parsers*. For instance to get the aforementioned function you could write:

    string_to_int_opt(s : string) : option(int) =
      Parser.try_parse(Rule.integer, s)
    

    or, if you want to be less verbose the equivalent:

    string_to_int_opt = Parser.try_parse(Rule.integer, _)
    

    or if it’s part of the more complex parsing you would just use the Rule.integer parser there.

    (*) I guess this section of the manual could use some extensions…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Traditionally, when we use SQL string to done some work, we have to close
Does anyone know how I can get a format string to use bankers rounding
You can use SelectFolder() to get a folder or GetOpenFolderitem(filter as string) to get
(please excuse that I didn't use aliases). I would like my query output to
I already asked similar question here, but I still get some errors, so I
public class TimeZone { public int Id { get; set; } public string DisplayName{
I just wrote some C code: #include <stdlib.h> #include <time.h> #include <string.h> typedef struct
If you have to use String.Replace() to replace test 50 times, you essentially have
It seems that the choice to use string parsing vs. regular expressions comes up
I'm looking for a portable and easy-to-use string library for C/C++, which helps me

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.