Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Foreach loop does not allow double i in "Text[]".Length

Discussion in 'Scripting' started by stoupas, Sep 12, 2023.

  1. stoupas

    stoupas

    Joined:
    Aug 26, 2021
    Posts:
    15
    So basicly I am making an app for my class at school where there is a leaderboard from dreamlo. But I want the leaderboard to show double variable and not int so when I put 0.9 to say 0.9 and not 0 I tryed everything but it doesnt seem to work The error message is "scirpt(15,25): foreach cannot operate on variable of type 'int' because 'int' does not contain a public instance or extension definition for 'GetEnumerator'".
     

    Attached Files:

  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,561
    You can fix your own typing mistakes. Here's how:

    Remember: NOBODY here memorizes error codes. That's not a thing. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind.

    The complete error message contains everything you need to know to fix the error yourself.

    The important parts of the error message are:

    - the description of the error itself (google this; you are NEVER the first one!)
    - the file it occurred in (critical!)
    - the line number and character position (the two numbers in parentheses)
    - also possibly useful is the stack trace (all the lines of text in the lower console window)

    Always start with the FIRST error in the console window, as sometimes that error causes or compounds some or all of the subsequent errors. Often the error will be immediately prior to the indicated line, so make sure to check there as well.

    Look in the documentation. Every API you attempt to use is probably documented somewhere. Are you using it correctly? Are you spelling it correctly?

    All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don't have to stop your progress and fiddle around with the forum.

    If you post a code snippet, ALWAYS USE CODE TAGS:

    How to use code tags: https://forum.unity.com/threads/using-code-tags-properly.143875/

    - Do not TALK about code without posting it.
    - Do NOT post unformatted code.
    - Do NOT retype code. Use copy/paste properly using code tags.
    - Do NOT post screenshots of code.
    - Do NOT post photographs of code.
    - ONLY post the relevant code, and then refer to it in your discussion.
     
  3. ijmmai

    ijmmai

    Joined:
    Jun 9, 2023
    Posts:
    188
    Can you post the code itself (in code tags) instead of the files?
     
    Bunny83 likes this.
  4. stoupas

    stoupas

    Joined:
    Aug 26, 2021
    Posts:
    15
    Sorry I will not be wanting that since I found another way that kinda works. I just tell them to put int instead of double
     
  5. ijmmai

    ijmmai

    Joined:
    Jun 9, 2023
    Posts:
    188
    What you wanted is possible, but if you are happy with the int workaround, that is fine too.

    Keep in mind people are more willing to take a look at your issues when they can see the code right away. Many, including myself, are not to fond of downloading files.
     
    Bunny83 likes this.