Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

scala

What are the changes when migrating from Scala 2.7?

Sarvech Qadir

Migrating from Scala 2.7 to Scala 2.8 or greater can cause some deprecation issues in some of the collections. In the newer releases, some features of Scala version 2.7 are present. However, the features that have deprecated will, in due time, be completely removed from Scala in future releases.

Whenever a programmer compiles the code on these deprecated features in Scala 2.8, they will get a deprecation warning.

Most of the features of Scala 2.7 are present in Scala 2.8, but some features have had their meaning or performance changed. This results in migration warnings when compiled.

A programmer can get the full details on deprecation warnings by adding the deprecation and -Xmigration flags while compiling the code.

Code

Let’s see the use of unzip command that has been deprecated:

>scala -deprecation -Xmigration
Welcome to Scala version 2.8.0.final
Type in expressions to have them evaluated.
Type :help for more information.
scala> val arr1 = List((1, 1), (2, 1))

scala> List.unzip(arr1)
<console>:7: warning: method unzip in object List is deprecated: use arr1.unzip instead of List.unzip(arr1)
       List.unzip(arr1)
            ^
res0: (List[Int], List[Int]) = (List(1, 1),List(2, 1))
scala> arr1.unzip
res1: (List[Int], List[Int]) = (List(1, 1),List(2, 1))

In the newest versions, several libraries have been replaced fully. For example, scala.collection.jcl package is removed. Instead, many programmers now use the java.util package directly.

RELATED TAGS

scala

CONTRIBUTOR

Sarvech Qadir
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring