notNull delegate vs lateinit seems similar, so I wonder when one is preffered over other?
notNullcreates an extra object for each property. The object is small, but if you have lots of properties, it can be significant for you.
- You can’t use the
notNulldelegate with external injection tools that injects directly to Java fields;
- You can’t create a
lateinitproperty of the primitive type (
lateinit is cheaper, but you can use only the delegate when your property has a primitive type.