Can I use the dot operator during braced initialization?

When asked how I’d initialize this data I thought we’d use the dot operator.
I was mistaken and thought maybe it was risky using data that was earlier initialized on the same line. But this works so now I wonder why he didn’t point this out. Is this acceptable?

1 Like

Not only is it acceptable, but in some cases can be the only way to get the data you need when initializing other variables.

We’re already making use of the dot operator when getting Nebula.height so all you’re doing differently is chaining dot operators to get data from an object inside of another object.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms