2

I'm new at C# and Unity and reading the Manual and encountered a foreign colon syntax in some examples:

function Choose(probs: float[]) {
var total = 0;

for (elem in probs) {
    total += elem;
}

var spawnPoints: Transform[];

function ChooseSet(numRequired: int) {
var result = new Transform[numRequired];

It's from Random Numbers Unity3d Manual

I found this question: Multiple Meanings of : in c#

But no one of the examples in this question seems to fit.

I think, it's a kind of type definition... but normally it would be

public Transform[] spawnPoints;

instead of

var spawnPoints: Transform[];

so I'm a little bit confused.

dbc
  • 104,963
  • 20
  • 228
  • 340

1 Answers1

8

The sample is in Unityscript (almost same as javascript or actionscript 3). The syntax is littlebit different, than syntax of C#.

Your tip is right. The

var spawnPoints:Transform[];

is in Unityscript and in C# it's exactly

Transform[] spawnPoints;
TcKs
  • 25,849
  • 11
  • 66
  • 104