2:50 this dream came true in Java ;) in Java 17 we have pattern matching in switch that works with recognizing different classes nice video overall, explains a lot
Your last sentence in the video cracked it for me. "Define specific implementations for certain types and not for others". It is unbelievably simple, you only need the right explanation, by the right guy. Thanks!
Ok let's write some compliments. That was the best, and the simplest explanation of type classes, and the first one which I was actually able to understand. Thanks good job.
You make hard things easy, you rock. I watch Rock the JVM videos as much as I can, I even have bought many courses on Udemy. I hope you soon start videos on cats-effect examples. Thanks a ton!
Amazing video. I have spent hours trying to understand the term. Turns out I have both used and employed type classes before, but have never made the connection between the term and what it implies despite having read multiple articles on it. Thank you so much!
Awesome video - short and upto the point. Can you please make some videos on the more functional programming concepts/constructs like side-effects, referential transprency, Mondas, Functors, IO Effects etc.
Nice tube, but in my opinion, isn't comfusing more than useful using implicit? I don't think I will remember what I did myself for while , what about the team I worked with, if I decide to use this topics??? for sure they thow the code in garbage and write another simply because they don't understand a thing??? what do you think about that?
Is there a way in Scala to make of use implicits in methods to choose implementaion based on same arguments but different return type? I tried the way below to return 5/"hello" based on return type defined for processMyList method call,with same argument. But fails with error 'ambiguous implicit values' object testTypeClass { trait Summable[T] { def sumElements(list: List[String]): T } implicit object IntSummable extends Summable[Int] { override def sumElements(list: List[String]): Int = 5 } implicit object StringSummable extends Summable[String]{ override def sumElements(list: List[String]): String = "hello" } def processMyList[T](list: List[String])(implicit summable: Summable[T]): T = { summable.sumElements(list) } def main(args: Array[String]): Unit = { val intSum: Int = processMyList(List("scala","is","awesome")) val stringSum: String = processMyList(List("Scala","is","awesome")) println(intSum) println(stringSum) } }
Implicits in general should be used VERY sparingly. This works here but when you’re reading older code and they use them, it almost always turns out to not be worth it.
@@rockthejvm Not really. I switch back and forth between movie & full screen mode. I watch short videos in movie mode and longer videos in full screen mode.
please don't ever stop making these type of awesome videos.
I was really struggling with this concept and this down to earth explanation has really helped a lot much thanks :)
2:50 this dream came true in Java ;) in Java 17 we have pattern matching in switch that works with recognizing different classes
nice video overall, explains a lot
Your last sentence in the video cracked it for me. "Define specific implementations for certain types and not for others". It is unbelievably simple, you only need the right explanation, by the right guy. Thanks!
Glad to hear it clicked! Share it if you think this would help someone!
Ok let's write some compliments. That was the best, and the simplest explanation of type classes, and the first one which I was actually able to understand. Thanks good job.
Glad it was useful!
You make hard things easy, you rock. I watch Rock the JVM videos as much as I can, I even have bought many courses on Udemy. I hope you soon start videos on cats-effect examples. Thanks a ton!
I'm in the business of making hard things easy. Enjoy!
Amazing video. I have spent hours trying to understand the term. Turns out I have both used and employed type classes before, but have never made the connection between the term and what it implies despite having read multiple articles on it.
Thank you so much!
Excellent explanation, you made type classes obvious. (as opposed to some other attempts to explain them).
Glad it clicked!
really great and simple explainer easy to understand.. big thanks
Thanks Daniel. This lesson is very inspiring!!
Thanks!
Awesome video. More of that!
Awesome video - short and upto the point. Can you please make some videos on the more functional programming concepts/constructs like side-effects, referential transprency, Mondas, Functors, IO Effects etc.
Will do!
My solute and 100% respect to you please accept. Your knowledge is awesome.
Also it would be interesting to mention where the name "type classes" comes from.
awesome explanation!
So gorgeously clear
Awesome video Daniel!
Glad you enjoyed it!
great content as always !
Excellent as usual :) Waiting for next videos
Thanks!
Thanks, good and short wxplanation
Awesome video! Finally cleared things up for me.
Glad it helped!
Nice tube, but in my opinion, isn't comfusing more than useful using implicit? I don't think I will remember what I did myself for while , what about the team I worked with, if I decide to use this topics??? for sure they thow the code in garbage and write another simply because they don't understand a thing??? what do you think about that?
Is there a way in Scala to make of use implicits in methods to choose implementaion based on same arguments but different return type? I tried the way below to return 5/"hello" based on return type defined for processMyList method call,with same argument. But fails with error 'ambiguous implicit values'
object testTypeClass {
trait Summable[T] {
def sumElements(list: List[String]): T
}
implicit object IntSummable extends Summable[Int] {
override def sumElements(list: List[String]): Int = 5
}
implicit object StringSummable extends Summable[String]{
override def sumElements(list: List[String]): String = "hello"
}
def processMyList[T](list: List[String])(implicit summable: Summable[T]): T = {
summable.sumElements(list)
}
def main(args: Array[String]): Unit = {
val intSum: Int = processMyList(List("scala","is","awesome"))
val stringSum: String = processMyList(List("Scala","is","awesome"))
println(intSum)
println(stringSum)
}
}
If I understand the question correctly: no, you can't pick which implicits to use. There can be only one for a given type.
The link ti the written form doesn't work: Sorry, we couldn't find that page
Updated link!
such an awesome video, explained well!
Thanks, Denial! Awesome video :) But can you add more examples of using this technic, I mean more real word?
I'm just getting started - will definitely add more content (and context) around this topic!
@@rockthejvm super! Because I see similar example, but I don't understand how to apply this in real word project 🤔
you definitely are my favorite Romanian !
Would be nice to menton some real world example where type classes are normally used.
Implicits in general should be used VERY sparingly. This works here but when you’re reading older code and they use them, it almost always turns out to not be worth it.
Very clear
You are awesome ^^
Nicely explained
Glad it clicked!
strategy pattern
It is kind of, but at a type generic level
Awesome
Glad you liekd it!
Multumesc!
Cu plăcere!
Tip: Try to make the font bigger. so much screen real estate - just wasted. Cheers.
Wow, really? My screen feels like a billboard when I record. Will do. Question: are you using the video on half the screen?
@@rockthejvm Not really. I switch back and forth between movie & full screen mode. I watch short videos in movie mode and longer videos in full screen mode.
Forgot to add that I have a 15" laptop. I don't have a big ,21" or greater, screen. Maybe that is sort of an issue, but on my side?