has been a topic that has caused troubles among many people I know learning Scala. Coming from and it could be difficult to correlate the term between the two languages. Implicits .NET C# implicit C# implicit conversions As the says MSDN pages The implicit keyword is used to declare an implicit user-defined type conversion operator. Use it to enable implicit conversions between a user-defined type and another type, if the conversion is guaranteed not to cause a loss of data. Basically we are transforming a data type into a different one preserving the information and without using . For example, the next example shows how these transformations are made. cast This particular feature improves code readability because the custom transformation is happening in a natural way, we avoid casting, while keeping the code clean enough. Scala implicit conversions In Scala, are basically the same as in with some syntax differences. implicit conversions C# Here we just saw how the two languages solve the same conversion problem, but there is something else about Scala that we can take advantage of and it is also what makes some developer coming from C# confused. implicits Type extensions in C#, we have the ability to extend types without creating new derived types. We can avoid the recompilation process of the original type and its modification using the or construct of the language. type extensions method extensions Lets see how this is done in C# Here we are extending the type and adding to it the method so we can do something like this: int plus This feature is very useful when it comes to extensibility and flexibility. Some are really hard to consume because they weren’t intended to be used for others until they are and being able to extend their types gives us control over third party . APIs assemblies In Scala, we have this same functionality but as mentioned before, some people coming from the C# world have problem understand it. We could use the same in Scala to solve the same problem that solve in C#. implicits method extensions Let’s suppose that we want to the type from Scala in the same way we did for C#. Here is how it goes. extend Int Let’s clear that the method has the return type explicitly declared because it is public API method, so return types should be declared to avoid conflicts if the in Scala changes. plus type inference systems In the last example, we have done the same we did in C#. We basically has define a way to extend the type, but in order to use it, we need to types. In order to achieve this, we do: Int change Important to note that when returning the class we are omitting the keyword because is a class. IntExtensions new IntExtensions case Now, we can use this extension in the same way we did in C#. This use of the Scala can cause a lot of problems when you have not seen it before. Probably the common use of is something everyone can understand but catching this use case in Scala requires a deeper knowledge of the language when coming from other languages such as C#. implicits changing types Notes in companion object in Scala This is out from our topic, but I think is a good idea to talk about it since its importance in the Scala language. It will let everyone understand better my last examples where we completely ignored the keyword when creating a instance. new IntExtensions There is a construct in Scala called . It basically defines a convenient way to create new instances of a particular type. companion object Lets define again the class, but this time NOT as a class. IntExtensions case The definition looks very close to the previous one except for the keyword. Now in order to create a new instance of this class we need to do case every time. It would be nice if we could do just instead. There is way to do it which is quite easy to implement. Let see how it gets done. Here we are declaring an with the same name of which has a function called and returns the actual instance. These two, the and its companion need to be define together in order to work. Now we can do something like this. object IntExtensions apply IntExtensions IntExtensions object This definition is the same as before, but remember that class is NOT a class anymore, so we need the keyword to create instance of it. What is happening is that the function from the companion object is being called when asking for an instance of it. IntExtensions case new apply IntExtensions This particular feature let us write very clean code in Scala, especially when using common types across the system, an example of this is creating lists. Instead of doing Even though it seems dumb, when code gets complicated it does help a lot, the Python programming language is an example of it. The C# language does not have this feature, yet, but there are tons of new features being added to the Microsoft programming language in order to catch up with the market. I hope this explanation about can help others coming from the Microsoft world to enjoy other programming languages in the same way I do. implicit is how hackers start their afternoons. We’re a part of the family. We are now and happy to opportunities. Hacker Noon @AMI accepting submissions discuss advertising & sponsorship To learn more, , , or simply, read our about page like/message us on Facebook tweet/DM @HackerNoon. If you enjoyed this story, we recommend reading our and . Until next time, don’t take the realities of the world for granted! latest tech stories trending tech stories