Skip to content
Discussion options

You must be logged in to vote

Hey @oliverfoggin! Sometimes, the compiler can have difficulties picking the Input type. In your case, you can nudge it in the right direction using the of: argument of Int.parser:

private enum Parsers {
  static let calories = Parse({ $0 }) {
    Many {
      Int.parser(of: Substring.self)
    } separator: {
      Whitespace(1, .vertical)
    } terminator: {
      Whitespace(1, .vertical)
    }
  }
}

SubString.self is already the default of this parameter, but it is not enough in this configuration for the compiler apparently.
The radix defines the "base" that is used, and allows to parse the hexadecimal "5F" as "95" in base 10 for example. In your case, you can keep the default value of…

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@oliverfoggin
Comment options

@tgrapperon
Comment options

Answer selected by oliverfoggin
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants