Skip to content

Allow init and set accessor in property #4164

Discussion options

You must be logged in to vote

I don't think that this would be possible as the init accessor already occupies the slot in the runtime for a set accessor. What you could do instead is to explicitly define your backing field and update it directly:

private sealed class WaitAction : Action
{
    private int ticks;
    public int Ticks {
        get => ticks;
        init => ticks = value;
    }

    public override bool MoveNext(Entity entity)
        => --ticks > 0;
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@FaustVX
Comment options

@333fred
Comment options

Answer selected by FaustVX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants