What's the best way to add component and get component?

Hey guys, what would be best practice to add a component and get it? I am sure the way I do it is wrong.

                            lGameObject.AddComponent<Rigidbody>().drag = .2f;
                            lGameObject.GetComponent<Rigidbody>().mass = 10f;
                            lGameObject.GetComponent<Rigidbody>().useGravity = true;

AddComponent returns the component that you’ve added, so you don’t need to use GetComponent after (especially multiple times). Instead just store the returned reference in a temporary variable, as multiple GetComponent calls is slower. Unless you’re a lot of this, the performance difference might not be noticeable, but there’s no reason not to re-use a single reference.

Rigidbody rb = AddComponent<Rigidbody>();
rb.drag = 0.2f;
rb.mass = 10f;
rb.useGravity = true