News for hackers. Stuff that matters.
Re:Introducing C# in Godot by Arnavion on Saturday October 21, 2017 @10:26PM (#15524816)
Note to the author: Since you specifically point out that C# 7.0 is supported, this example:

    if (ev is InputEventMouse)
    {
        var mouseEvent = (InputEventMouse)ev;
        Vector2 mousePos = mouseEvent.Position;
    }
    else if (ev is InputEventKey)
    {
        var keyEvent = (InputEventKey)ev;
        bool aPressed = keyEvent.Pressed && keyEvent.Scancode == GD.KEY_A;
    }
would be better written as:

    switch (ev)
    {
        case InputEventMouse mouseEvent:
            Vector2 mousePos = mouseEvent.Position;
            break;

        case InputEventKey keyEvent:
            bool aPressed = keyEvent.Pressed && keyEvent.Scancode == GD.KEY_A;
            break;
    }
Re:Introducing C# in Godot by tonyedgecombe on Sunday October 22, 2017 @06:56AM (#15526152)
Or:

    if (ev is InputEventMouse mouseEvent)
    {
        Vector2 mousePos = mouseEvent.Position;
    }
    else if (ev is InputEventKey keyEvent)
    {
        bool aPressed = keyEvent.Pressed && keyEvent.Scancode == GD.KEY_A;
    }
Re:Introducing C# in Godot by knocte on Sunday October 22, 2017 @04:21AM (#15525740)
I think switch blocks are only worth it when you have 2 or more `else if`, otherwise a normal `if` is more readable IMHO.
Re:Introducing C# in Godot by n4r9 on Sunday October 22, 2017 @04:44AM (#15525780)
Normally I'd agree, but I really like the concise but readable way this handles the casting for you.
Re:Introducing C# in Godot by andybak on Sunday October 22, 2017 @06:02AM (#15525968)
It might be if they used the One True Brace style ;)