I just took the Kotlin badge test on LinkedIn. It ...
# announcements
I just took the Kotlin badge test on LinkedIn. It doesn’t tell me the answers so I don’t know for sure. There are a LOT of small wording problems in the quiz where it’s not clear if they are trying to gotcha you or not. i.e. They show you a function and call it
, but the correct answer calls the function
. There were lots of small little mistakes in the correct answers that make you question whether or not it’s the correct answer.
K 2
Also why does
exist when there is
I haven't seen that test, but Delegates.notNull() existed before lateinit, and still has some uses: for example, primitives can't be lateinit, but can be Delegates.notNull()
plus one 1
The question was something like “If you want to have a variable that is set later, but can’t be null, what should you do?“. I wasn’t sure if
was a thing, and based on their previous mistakes I questioned whether they were referring to lateinit as a delegate. 😛 Obviously I missed that one.
Is lateinit just compiling down to the raw variable access with some inlined checks before the access?
oh - thats what’s happening, only they create functions instead of inlining the checks:
Copy code
public static String test;

   public static final String getTest() {
      String var10000 = test;
      if (var10000 == null) {

      return var10000;

   public static final void setTest(@NotNull String var0) {
      Intrinsics.checkNotNullParameter(var0, "<set-?>");
      test = var0;
another important thing you can see with the lateinit var: it exposes the raw field so that Java dependency injection libraries can access it
btw, if it's a private member, it is raw field accesses
You have a lot of specialized lateinit knowledge. 😄 Why do you know all this off the top of your head?
regarding private raw field access, that happens for all properties, not just lateinit
regarding DI/backing field, that was part of the original design. https://youtrack.jetbrains.com/issue/KT-9067
I guess I knew that about properties too. I just haven’t thought about it for a few years. I also haven’t used that method of DI for 4 or so years now either.