how to add physic layer to an object via scripting?

in edit-project settings- physics, we have "layer collision matrix". and every object has a "layer" dropdown list next to it's "tag" dropdown list. I created a physic layer in editor, and i know how to assign them in editor. but how to assign a specific physic layer via scritping? (for example, to an object created at runtime)

gameObject.layer = LayerMask.NameToLayer("Layer Name");