0 votes

Hi, I cannot use the following syntax with is operator type pattern matching. It is just annoyance, but I would like to know official plans, if it will be supported:

public override void _Input(InputEvent event0){
    if(event0 is InputEventMouseButton mbe){ //HERE
        if(mbe.Pressed && mbe.ButtonIndex == (int)ButtonList.Left){
            GD.Print("Click!");
}}}

Errors:
Scripts\Paddle.cs(16,44): error CS1026: ) expected
Scripts\Paddle.cs(16,47): error CS1002: ; expected
Scripts\Paddle.cs(16,47): error CS1513: } expected

Env:
Windows 10 x64
Godotv3.1.1-stablemono
Microsoft (R) Build Engine version 14.0.23107.0
Mono version 5.20.1.19

This works:

if(event0 is InputEventMouseButton){
    var mbe = event0 as InputEventMouseButton;

This too:

var mbe = event0 as InputEventMouseButton;
    if(mbe != null){

C# style guide says I need to stick with C# 6.0
But in official docs it is used type pattern matching

asked Jun 16, 2019 in Engine by plyr0 (12 points)

I created an issue in the documentation repository about this: https://github.com/godotengine/godot-docs/issues/2540

Installed Visual Studio 2019 Community, and it works great. Probably MSBuild 15/19 alone would be also fine. Thanks for help.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.