x


How can I overload operators in Unity Javascript

I tried using this code to modify the [] operator:

static operator [] ( iRow:int ):float { return parseFloat(m[iRow]); }

it did not work but in the unity reference, there were some operator overloads defined in the same way.

more ▼

asked May 31 '10 at 05:36 PM

bimboladimeji gravatar image

bimboladimeji
41 5 5 7

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

There isn't a [] operator.

In c# you can created indexers (the things arrays and hashtables use) like this:

public string this[string key]
{
    return internalStringDictionary[key];
}

but i don't think js has the relevant syntax to express it

more ▼

answered May 31 '10 at 06:29 PM

Mike 3 gravatar image

Mike 3
30.5k 10 65 253

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x39
x16

asked: May 31 '10 at 05:36 PM

Seen: 1310 times

Last Updated: May 31 '10 at 05:36 PM