implicit classes

close up photo of gray laptop

Should implicit classes always extend AnyVal in Scala?

Reading Time: 3 minutes What are implicit classes? Implicit classes are a feature that allow you to extend the functionality of existing types by adding new methods. They are defined using the implicit keyword and have a single constructor parameter. We can use these class as if they belong to the original type without having to perform explicit type conversion. Implicit classes are particularly useful for adding utility methods Continue Reading

Implicit Classes in Scala- Their Uses and How to create them?

Reading Time: 2 minutes What is an implicit class An implicit class in Scala is a normal scala class but with an implicit keyword before it. They allow the user to add methods to exiting classes and use them as if they belong to those classes. The feature is available since Scala 2.10. This is how we declare an implicit class in Scala: In short, they allow us to Continue Reading

Let’s talk about Implicit

Reading Time: 6 minutes I hope from the above picture you can get an idea of “how an implicit can be useful”. This is just a single use case and if you are more interested in knowing about Implicit then this blog is for you. In this blog, I am going to discuss Implicit in Scala. I hope this will be useful to you. So, let’s talk about implicit Continue Reading

Implicit Conversions In Scala: Let’s extend Functionality

Reading Time: 3 minutes Hello folks, in this blog we will see Implicit Conversions in Scala language. And how it helps to make our code more readable. Before going into much detail about implicit let’s understand why we need implicit in Scala. There is a basic difference between your own code and libraries of other people. You can change your code as your need but when you have to Continue Reading

Back2Basics: The Magic of Implicit – #2

Reading Time: 3 minutes In our previous blog, The Magic of Implicit, we have talked about how implicit values are being used. In this blog, we will explore Type Conversion with implicit and implicit classes. Let’s start with a simple example, scala> val i: Int = 2.3 <console>:11: error: type mismatch; found : Double(2.3) required: Int val i: Int = 2.3 Here we were trying to assign a double type value Continue Reading