Тёмный

Given and Using Clauses in Scala 3 | Rock the JVM 

Подписаться
Просмотров 6 тыс.
% 270

Scala 3 New Features course for Scala 2 developers:
rockthejvm.com/p/scala-3-new-features
Written version: blog.rockthejvm.com/scala-3-given-using/
This video will continue the Scala 3 journey. This one is pretty important as it covers the new "contextual abstractions": given instances and using clauses.
In this video, I'll walk you through the kind of problems it solves, how to import given values, how to derive givens from other givens, and the general problems this new mechanism was designed to solve.
How to get started with Scala 3/Dotty:
Option 1: install IntelliJ IDEA at jetbrains.com/idea with the Scala plugin which offers support for Scala 3/Dotty
Option 2: check the official Dotty instructions at dotty.epfl.ch/docs/usage/ide-support.html
Follow Rock the JVM on:
LinkedIn: linkedin.com/company/rockthejvm
Twitter: rockthejvm
Blog: blog.rockthejvm.com
-------------------------------------------------------------------------
Home: rockthejvm.com
-------------------------------------------------------------------------

Наука

Опубликовано:

 

16 ноя 2020

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 23   
@hoangnhatpham8076
@hoangnhatpham8076 3 года назад
Can't wait for the new type-level program series on Scala 3!
@rockthejvm
@rockthejvm 3 года назад
Soon to come!
@EricKolotyluk
@EricKolotyluk 3 года назад
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 года назад
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) }
@rockthejvm
@rockthejvm 3 года назад
Yep.
@peterstorm_io
@peterstorm_io 3 года назад
They just announced new syntax for importing givens, by the way - check the blog. Awesome video though, as always!
@rockthejvm
@rockthejvm 3 года назад
Thanks!
@MarkvanBuskirk
@MarkvanBuskirk 3 года назад
That was a damn good introduction.
@rockthejvm
@rockthejvm 3 года назад
Glad to hear it!
@valcron-1000
@valcron-1000 3 года назад
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 3 года назад
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!
@vetiarvind
@vetiarvind 2 года назад
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 года назад
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
@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.
@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
@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 3 года назад
please help me to identify how it is different from Implicit?
@rockthejvm
@rockthejvm 3 года назад
The given/using clauses will replace the implicit mechanism. Video coming today!