Late Initializers #327
Replies: 3 comments
-
I'm not opposing this idea, but isn't it just introducing a var foo = new Bar();
foo {
a : "One",
b : 2
} I'm sure I read recently that there are problems with |
Beta Was this translation helpful? Give feedback.
-
@DavidArno I think a difference is one line vs multiple lines, and expression body everything idea.
or did you mean something like
|
Beta Was this translation helpful? Give feedback.
-
No, I didn't mean that, so I guess my code isn't clear. With what you propose, I could do: var foo = new Bar();
// some code
var bar = foo {
a : "One",
b : 2
} But var foo = new Bar();
// some code
_ = foo {
a : "One",
b : 2
}
// foo.a is now "One", foo.b is 2 But why have that var foo = new Bar();
// some code
foo {
a : "One",
b : 2
} At this point we have a var foo = new Bar();
// some code
foo {
a : "One",
b : 2,
SomeMethod()
} And now it's a complete |
Beta Was this translation helpful? Give feedback.
-
One of the things I miss when working with Tasks and DI is simple initialization.
It would be nice to be able to do this with injected things
or Task results
Beta Was this translation helpful? Give feedback.
All reactions