I propose we allow indexers, collections, and events to be assigned during construction. Currently, only properties and fields are allowed. An indexer is a property too, why can't we assign to it during construction?
As an extension to #877, I propose we allow:
let p = Builder([2] = initializeToIndexer, collection @= [addToCollection1; addToCollection2], event @= [addToEvent1; addToEvent2], Property = (SubLevelProp1 = 2, SubLevelProp2 = 1))
The existing way of approaching this problem in F# is
let p = Builder()
p.[2] <- initializeToIndexer
p.collection.Add addToCollection1
p.collection.Add addToCollection2
p.event.Add addToEvent1
p.event.Add addToEvent2
p.Property.SubLevelProp1 <- 2
p.Property.SubLevelProp2 <- 1
Pros and Cons
The advantages of making this adjustment to F# are
- Conciseness
- Convenience - property initialization works with more things!
The disadvantages of making this adjustment to F# are that @= may have already been defined in user code. However, as with nameof, this can be solved by a library intrinsic.
Extra information
Estimated cost (XS, S, M, L, XL, XXL): M
Related suggestions: #877
Affidavit (please submit!)
Please tick this by placing a cross in the box:
Please tick all that apply:
For Readers
If you would like to see this issue implemented, please click the 👍 emoji on this issue. These counts are used to generally order the suggestions by engagement.
I propose we allow indexers, collections, and events to be assigned during construction. Currently, only properties and fields are allowed. An indexer is a property too, why can't we assign to it during construction?
As an extension to #877, I propose we allow:
The existing way of approaching this problem in F# is
Pros and Cons
The advantages of making this adjustment to F# are
The disadvantages of making this adjustment to F# are that
@=may have already been defined in user code. However, as withnameof, this can be solved by a library intrinsic.Extra information
Estimated cost (XS, S, M, L, XL, XXL): M
Related suggestions: #877
Affidavit (please submit!)
Please tick this by placing a cross in the box:
Please tick all that apply:
For Readers
If you would like to see this issue implemented, please click the 👍 emoji on this issue. These counts are used to generally order the suggestions by engagement.