Traits

Object-Oriented Programming in Scala

Reading Time: 3 minutes Object-oriented programming (OOP) is a computer programming model that organizes software design around data, or objects, rather than functions and logic. Scala is also an Object-Oriented language and in this blog, we will see how we achieve that in scala. Classes in Scala Class is like a blueprint for a real-world entity which we call object in programming languages. It provides the initial values for state Continue Reading

Iterator producing iterator in Rust is really helpful.

Reading Time: 4 minutes If you are a little bit familiar with programming, you might have heard about an iterator. It is quite useful as it allows to access each item of an iterable and perform various operations as well. Let us explore it more and learn about some cool methods of iterators in Rust that produce other iterators.

Rust Closures will make your life easy

Reading Time: 4 minutes Rust closures are a very helpful and efficient feature of Rust. Closures are quite useful as it allows environment capturing. Let’s explore it together and learn more about it.

Scala Trait: The Magnificent feature that enables Multiple Inheritance

Reading Time: 5 minutes In this blog, we will discuss Scala Trait and how it helps us to implement multiple inheritance in Scala and to increase code reusability. What is Trait? According to the dictionary, a Trait is a distinguishing property or feature, typically one belonging to a person or genetically determined characteristics. In Scala, Trait encapsulates methods and field definitions that can be re-used by extending them into Continue Reading

Difference Between Abstract Class and Trait in Scala

Reading Time: 4 minutes In this blog we’ll go through the practical difference between the Abstract class and Trait in Scala. I. OVERVIEW Firstly, Let me give you a brief introduction on what Abstract class and Traits are in Scala. After that we’ll start with the differentiation. ABSTRACT CLASS Abstraction means hiding the internal details and showing only the functionality. And, In Scala abstraction is achieved by using abstract Continue Reading

Introducing Transparent Traits in Scala 3

Reading Time: 2 minutes I am learning Scala 3 and as I go along, I want to share about it with our community. In this quest, I had written an article a few days back on Trait Parameters in Scala 3. Check it out! In this article, I am going to write about a new feature of Scala 3, called Transparent Traits. Firstly, we will look into the problem Continue Reading

Scala Beginner Series (2) : Object Oriented Scala

Reading Time: 7 minutes This series is all about the taste of Scala.It is best suitable for all the newbies in Scala. You may also like: Scala Beginner Series (1) : Basics In the previous part, we covered: Values, variables, expressions and types Functions and recursion The Unit type This article will cover the object oriented nature of Scala language. Classes Scala has the same concept of a class as we Continue Reading

Scala Traits – Let’s mix it up a bit

Reading Time: 6 minutes Scala has way too many unique features that have always stunned the developers worldwide. Some of its features like Lazy evaluation, case classes, etc. have totally changed the coding standards for good. In this blog today, we will be taking you on a small tour to one of these unique and mesmerizing features that Scala has in store for its users i.e Scala Trait Mixin. Continue Reading

Back2Basics: The Story of Trait – Part 4

Reading Time: 4 minutes In our previous blog The Story of Trait – Part 3, we have discussed the mixin, one of the charming feature of traits. Now we are going to explore chaining of traits. We have seen how can we mix more than one traits into classes. But what would happen if two traits have same method i.e same name and same signature? This is where Multiple Inheritance Continue Reading

Back2Basics: Catalogue #1

Reading Time: 2 minutes Knoldus Inc is proud to announce the launch of program “Back2Basics”. Back2Basics is our effort to add value to the Scala ecosystem by exploring not so explored concepts in Scala. The idea behind the inception of the program is to develop an understanding of Scala concepts that are hard to understand and not frequently used by developers. In this program, we have two parallel tracks Continue Reading

Back2Basics: The Story of Trait – Part 3

Reading Time: 4 minutes In our previous blog The Story of Trait – Part 2, we have discussed that traits can have implementation too and how they behave under the hood. In this blog, we will discuss mixins one of the most charming features of traits. Mixins are the wonderful concept of object-oriented programming. Sadly, some of the mainstream object-oriented programming languages like C++, Java, C#, have not provided Continue Reading

Back2Basics: The Story of Trait – Part 2

Reading Time: 3 minutes In our previous blog The Story of Trait – Part 1, we have discussed how traits are the just regular interfaces at the very basic form. In this blog, we will explore about traits can have method implementation too. We will continue with our previous example and modify it and see how trait behaves in different scenarios. https://gist.github.com/mahesh2492/912fa3da297660afc96c657815610e2d.js This file contains bidirectional Unicode text that Continue Reading

Back2Basics: The Story of Trait – Part 1

Reading Time: 3 minutes In this blog, we will have a look at traits in Scala. We have classes in Scala. Suppose we have a class Dog which has a method speak. class Dog(val name: String){ def speak() = println(s”$name is barking”) } Now if we want another class Cat which has the same method speak. What we will do? In Java, generally, we create an interface Animal and Continue Reading