Parser error on "match"

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By robertop
:warning: Old Version Published before Godot 3 was released.

Sorry for the beginner question, but I have the follow code:

func _checkResult():
    var tam = defenseSeq.length()
    match tam:
        0:	print("Teste 0")
	    1:	print("Teste 1")

And the Godot show the follow error:
Parser Error: Expected end of statement after expression.
And the line is the line of “match tam:”

I don’t understand the problem :frowning:

That looks like a bug. Try var x = match tan: ... ?
Is it Godot master branch?

Zylann | 2017-01-20 12:46

If I put

	var x = match defenseSeq[tam-1]:

the error is Parser Error: Expected end of statement (var)

I using the RELEASED 2016/11/17. The oficial stable version.

robertop | 2017-01-20 13:22

Just was going to ask, match is on stable?

eons | 2017-01-20 14:29

:bust_in_silhouette: Reply From: Zylann

You cannot use match on Godot 2.1.1, it will be available only in 3.0. You can tell it’s not supported because the script editor doesn’t highlight the keyword.

Ok! Thanks… But this isn’t clear in doc for version 2.1…

robertop | 2017-01-24 13:58