Search code examples
declarationvargdscript

What is the use of the colon in variable declaration?


In GDscript, what is the difference between this two variable declarations?

extends Node

var n = 10
var m: = 10

Solution

  • The first one var n = 10 is an assignment but n has no type. The second one var m: = 10 is also an assignment but m now is an integer.

    The second one is equal to:

    var m: int
    m = 10
    

    For more info you can read this.