![]() |
In this discussion, we will explore abstract types and generics in Scala, highlighting their differences. Abstract types are types that include abstract members, while generics are types that can take other types as parameters. Let’s delve into the disparities between these two concepts. Scala Abstract Types vs GenericsAbstract Type:
For example: Consider a trait named Container, which has an abstract type Item and variable contents of type Item. Scala Code
In simpler terms, abstract types are placeholders for types that do not have a specific implementation yet. They allow us to define structures without committing to specific types until later. Generics:
Scala Code:
Difference between Abstract types and Generics
|
Reffered: https://www.geeksforgeeks.org
Scala |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |