Replies: 1 comment 2 replies
-
Withers were not implemented to work with indexers, only properties. I don't know if there was an explicit decision against supporting indexers, there probably wasn't a good use case for it. I can imagine it being considered a pit of failure given that unless the type is carefully designed that such an indexer would result in mutating both the instances of the type. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm having trouble figuring out if this is a feature gap or if I'm just using it wrong. I've got a bunch of small
readonly struct
s that I'm using in a performance-critical section of my code, and I'm using thewith
expression from C#10 to do nondestructive mutation. I thought that you could use any syntax you could in anew() { ... }
initializer list, but the compiler complains if I try and assign to an indexer:Shouldn't indexers be treated the same as other properties in
with
expressions? If so, what's wrong with my code?Beta Was this translation helpful? Give feedback.
All reactions