We fixed an inconsistency in Kotlin (non-local break & continue)

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 ม.ค. 2025

ความคิดเห็น • 26

  • @AlanDarkworld
    @AlanDarkworld 15 วันที่ผ่านมา +34

    Non-local breaks and continues are... whatever. I would avoid them in clean code anyways. What I find exciting are the contracts. When will they become stable?

    • @cromefire_
      @cromefire_ 15 วันที่ผ่านมา

      I mean the contracts have been in there for so long, I'd wager they won't change that much anymore anyways. And you also don't need to declare them that often. At least I've just been using them for a while now.

    • @ErikBongers
      @ErikBongers 12 วันที่ผ่านมา

      The Wikipedia page on the goto statement lists a couple of reasons why it could be used although, generally it's discouraged. Amongst them, more readable code and less code duplication are mentioned.
      I'd say that these non local breaks are similar.
      Non local breaks look wrong, but are they really that problematic?

    • @cromefire_
      @cromefire_ 12 วันที่ผ่านมา

      @@ErikBongers I mean you can always enforce labels on them with something like detekt for example, if they implement that as a rule.

  • @donwald3436
    @donwald3436 15 วันที่ผ่านมา +7

    0:00 Bro this isn't tiktok you don't need the ADHD captions lol.

  • @CrapE_DM
    @CrapE_DM 14 วันที่ผ่านมา +4

    I feel like your lighting makes your face seem flatter than it really is

  • @abiofficial-ws7pn
    @abiofficial-ws7pn 11 วันที่ผ่านมา +1

    Thank you, Saif Ali Khan.

  • @ErikBongers
    @ErikBongers 12 วันที่ผ่านมา +1

    Like others have said, non local breaks feel wrong to me as well, but I like how Kotlin is experimenting with coloring-outside-the-lines constructs and syntax like last argument lambdas. Those are also "wrong". As long as the code doesn't become more ambiguous to the reader, let's give it a try.

  • @gargleblasta
    @gargleblasta 12 วันที่ผ่านมา

    9:28 that is very nice, but what if the onfailure function that executes the lambda executes it in a loop himself? Which loop would the break be executing? Would it require to know the internal working of onfailure before using break?

  • @hashemmousavi2451
    @hashemmousavi2451 15 วันที่ผ่านมา

    Awesome as always

  • @albetn.2412
    @albetn.2412 14 วันที่ผ่านมา

    So this makes the lambda could break or continue a loop where the lambda executed on?

  • @mirrana491
    @mirrana491 15 วันที่ผ่านมา +3

    TOMATO IS A FRUIT LMAO

  • @alco8864
    @alco8864 15 วันที่ผ่านมา +1

    wow, how to color the suspend method @@?

    • @EugeneGalonsky
      @EugeneGalonsky 15 วันที่ผ่านมา +2

      Settings->Editor->ColorScheme->Kotlin->Functions->Suspend function call

  • @AK-vx4dy
    @AK-vx4dy 15 วันที่ผ่านมา

    Felixble but what for extract lambda to tie it again to specific code?
    I see some use in UI scenarios

  • @Vatk4LI
    @Vatk4LI 15 วันที่ผ่านมา

    thats a great feature

  • @kiyo211
    @kiyo211 14 วันที่ผ่านมา +2

    Awesome content (i didn't understand anything)

  • @aazzrwadrf
    @aazzrwadrf 13 วันที่ผ่านมา +1

    I always disliked how the scoping of exit statements works in Kotlin. It should exit the current block by default. It's unintuitive and breaks copy-paste.

  • @MaxWeninger
    @MaxWeninger 15 วันที่ผ่านมา +7

    Not sure why to write such code that needs this in the first place? Beeing "flexible" does not include writing such weired code :)

  • @waelluay6902
    @waelluay6902 14 วันที่ผ่านมา

    What's the name of the theme?

    • @TheIsraelMendoza
      @TheIsraelMendoza 14 วันที่ผ่านมา +1

      It looks like IntelliJ’s default “Dark”.

  • @Salehalanazi-7
    @Salehalanazi-7 15 วันที่ผ่านมา +1

    I like allowing this but it feels smelly

  • @ErikBongers
    @ErikBongers 12 วันที่ผ่านมา

    To the people insisting on using the biological classification of fruits instead of the culinary one, feel free to also add cucumber, olives and many more to your fruit salad. And since strawberries and rhubarb are not biological fruits, we'll add them to your soup. Enjoy.

  • @sensitive-cod
    @sensitive-cod 15 วันที่ผ่านมา

    onSuccess and onFailure methods are methods that are potentially asynchronous in nature. Thats a bad naming for what you are trying to achieve. Substituting if (result.isFailure) { break } with a result.onFailure { break } is super smelly and, I'd dare to say, dangerous!

  • @yalfdev
    @yalfdev 15 วันที่ผ่านมา

    Great feature..but Tomato is a real fruit lol

  • @julio_souza
    @julio_souza 15 วันที่ผ่านมา

    You are correct on not liking the number 13, it is also a bad number in Brazil.