Weird List error

About Monkey 2 Forums Monkey 2 Development Weird List error

This topic contains 2 replies, has 2 voices, and was last updated by  EdzUp 1 year, 4 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #11933

    EdzUp
    Participant

    when indexing a list with a for..next loop you sometimes get:
    ????? [68] : Error : Types ‘monkey.types.Int’ and ‘monkey.types.Int()’ are incompatible

    this error is generated when you do something like:
    For x=0 to MyList.Count..Next

    instead of:
    For x=0 to MyList.Count()..Next

    Its just the brackets that are missing but its a really weird error for just that and something that could stump some coders.

    #11938

    abakobo
    Participant

    It’s not really weird. It’s first class functions. If you forget the brackets you’ll pass the function itself not it’s result. But it’s true it’s a bit surprising the first time.

    #11939

    EdzUp
    Participant

    I would have made the variable private so monkey cannot call it directly and only the function is parsed by the IDE. Then just a error like “Count cannot be accessed like this”

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.