• Godot Help
  • How do I specify an annotation for an array of Strings?

var skills := ["Block", "Swing"]

func choose_random_skill(skills: ?) -> String:
return ""

I'm not sure what to put in ?. I was able to fix this code by using var skills: Array[String] = ["Block", "Swing"], but what do I use if it's not typed in the initialization?

In this case, you would use type inference to determine the type that should be used. Type inference is the process of automatically determining the type of a given expression. In this case, you would simply use the type [String] to indicate that the array contains elements of type String. The updated code would look like this:

var skills: [String] = ["Block", "Swing"]

func choose_random_skill(skills: [String]) -> String:
return ""

    You don't need to specify argument's type at all. It's optional.
    The correct syntax is Array[String]:

    func choose_random_skill(skills: Array[String]) -> String:

    Btw arrays have built in method for choosing a random element. It's Array::pick_random().

    DaveTheCoder Makes me question why she exists then. If she can and will give wrong answers in a forum setting where users are the backbone of community, sharing and receiving help, where does a bot that can and will give incorrect info to potential newbies fit in?

    Maybe in the future she will be able to give more accurate and correct answers. But that takes feedback and alot of wrong answer slung about. Seems totally redundant. I'm heavily anti-ai in learning environments and I'm well aware of that

    It's an experiment. She's been here less than a week. It would be reasonable if the bot had its own forum, or only replied when addressed directly, but the bot plugin lacks configuration options.

    I don't think she'll be here much longer.