Problem with functions

I want to create a function like this:
function addThing (thing1 [thing2 : String, thing3 : String]){
//do a thing
but it doesn’t work.
Can someone help me?

I see three ways to interpret this question...

1) if you mean optional parameters, unityscript does not support that; there's an excellent set of answers already for how to achieve the same result here.

2) If you mean you want to take in an array objects as a parameter, the syntax for that is:

function AddThings(things:String[]){
   for (var thing in things)
       //do a thing with thing

3) if you're trying to do haskell-style lists, unityscript doesn't support that. You'll have to accept multiple parameters or formally define a class to represent the list.

If you mean something else entirely, you'll have to explain. Even if you did mean one of these things, please be more clear in the future about what you're trying to accomplish, as it's hard to answer such a vague question.

For C#:

Make the last parameter an array that has they keyword params before it.

Examples are all over the GUILayout class, such as , where you see the widget function takes in a variable number of GUILayoutOptions

I have optional parameters all over the place, but I’m using C#. Your usage may vary with other languages. Hard to tell what you are doing in your example.

function Ownage(int x, int y = 3, int z = 5) {   // y and z are optional