Skip to content

Enhanced var pattern #7181

May 9, 2023 · 2 comments · 9 replies
Discussion options

You must be logged in to vote

Since every line in your example should unconditionally succeed, I'd turn this around and say that having nominal deconstruction with var would be the ideal way to approach the first:

var {
    RefProperty: ref r,
    RefProperty2: ref readonly s,
    RefReadOnlyProperty: ref readonly t,
} = expr;

The next would be list destructuring which hasn't been discussed yet that I'm aware of, but which keeps coming to my mind as we work on collection literals (@CyrusNajmabadi):

var [ref a, ref readonly b, ..] = span;

The last is already possible in the ideal (unconditional) form today:

ref var r = ref Method();

Replies: 2 comments 9 replies

Comment options

You must be logged in to vote
6 replies
@DavidArno
Comment options

@HaloFour
Comment options

@KyouyamaKazusa0805
Comment options

@DavidArno
Comment options

@FaustVX
Comment options

Comment options

You must be logged in to vote
3 replies
@KyouyamaKazusa0805
Comment options

@jnm2
Comment options

jnm2 May 10, 2023
Collaborator

@KyouyamaKazusa0805
Comment options

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