notNull delegate vs lateinit


#1

Hello
notNull delegate vs lateinit seems similar, so I wonder when one is preffered over other?


#2
  • notNull creates 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 notNull delegate with external injection tools that injects directly to Java fields;
  • You can’t create a lateinit property of the primitive type (Int, Long, etc).

lateinit is cheaper, but you can use only the delegate when your property has a primitive type.