Given and Using Clauses in Scala 3 | Rock the JVM

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 พ.ย. 2024

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

  • @hoangnhatpham8076
    @hoangnhatpham8076 4 ปีที่แล้ว +11

    Can't wait for the new type-level program series on Scala 3!

  • @EricKolotyluk
    @EricKolotyluk 3 ปีที่แล้ว +1

    I am really loving this channel. As someone who has always hated implicits in Scala, I really welcome not only the new given/using, but how this channel explains things so well...

    • @rockthejvm
      @rockthejvm  3 ปีที่แล้ว

      Thanks, Eric, really glad you like the stuff here!

  • @DinoFancellu
    @DinoFancellu 3 ปีที่แล้ว +4

    The latest intellij (2021.2.1) doesn't seem to offer Dotty per se, but does offer Scala 3
    It looks like Givens have changed, "as" isn't accepted, but this is
    given standardPersonOrdering: Ordering[Person] with {
    override def compare(x: Person, y: Person): Int = x.surname.compareTo(y.surname)
    }

  • @peterstorm_io
    @peterstorm_io 4 ปีที่แล้ว +2

    They just announced new syntax for importing givens, by the way - check the blog. Awesome video though, as always!

  • @hariprasad6777
    @hariprasad6777 2 ปีที่แล้ว

    Hi, I am not getting Scala options even after installing plugins during new project creation....I am trying with community edition 2022.2.x, SBT 1.7.1 and scala3.x...pls suggest

  • @colin398
    @colin398 ปีที่แล้ว

    Writing out the "optionOrdering" given clause gives me a syntax error. Bloop tells me "not found type optionOrdering". Maybe I'm missing something.

  • @MarkvanBuskirk
    @MarkvanBuskirk 3 ปีที่แล้ว +1

    That was a damn good introduction.

    • @rockthejvm
      @rockthejvm  3 ปีที่แล้ว

      Glad to hear it!

  • @vetiarvind
    @vetiarvind 2 ปีที่แล้ว +1

    given/using is just like implicit right? i wonder why they did this, maybe it's easier to trace the plumbing instead of the "wifi" of implicits.

    • @rockthejvm
      @rockthejvm  2 ปีที่แล้ว +1

      The implicit keyword was overloaded with 3 different goals, which are now split for easy comprehension:
      - implicit args/values/generators -> now givens
      - implicit conversions -> now you need to bend over backwards to do them
      - implicit classes -> now extension methods

  • @valcron-1000
    @valcron-1000 4 ปีที่แล้ว +2

    Great video, now I understand how type-classes are implemented in Scala. Pretty neat that you can name the "instances", helping you avoid instance clashes.
    Could you share how to build and deploy Scala (pref. 3) code? I had a hard time trying to build and deploy self-contained apps (single executable, no *.jar, no JVM prerequisite) in Java/Kotlin, so I would like to know how could you achieve this in Scala.

    • @rockthejvm
      @rockthejvm  4 ปีที่แล้ว +1

      Glad it helped! Scala 3 isn't out yet, so it might take a bit before we have this in a real-life scenario, but we're getting there!

  • @RobinHillyard
    @RobinHillyard ปีที่แล้ว

    Did the mechanism of getting implicit types from the object of an involved type go away in Scala 3?

    • @rockthejvm
      @rockthejvm  ปีที่แล้ว

      wdym?

    • @RobinHillyard
      @RobinHillyard ปีที่แล้ว

      @@rockthejvm It's just that you didn't mention that mechanism for satisfying the implicit/given type.

  • @saurabhdubey8528
    @saurabhdubey8528 4 ปีที่แล้ว

    please help me to identify how it is different from Implicit?

    • @rockthejvm
      @rockthejvm  4 ปีที่แล้ว +1

      The given/using clauses will replace the implicit mechanism. Video coming today!