notNull delegate vs lateinit

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

  • 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.

3 Likes