"=>" Meaning

So I have a little script reference setup, what does => mean exactly in this situation?

public static NewBehavior Instance
void Awake() => Instance = this;

That’s an expression-bodied method. It’s just syntax sugar for making a one-statement / expression method. Equivalent to:

void Awake()
{
  Instance = this;
}

It’s usually more useful for methods with a return value.

int GetValue()
{
  return 5;
}
int GetValue() => 5;

The above do the same thing.

7 Likes