kandi X-RAY | scala-tutorials Summary
kandi X-RAY | scala-tutorials Summary
scala-tutorials
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of scala-tutorials
scala-tutorials Key Features
scala-tutorials Examples and Code Snippets
Community Discussions
Trending Discussions on scala-tutorials
QUESTION
I am taking a basic Scala training offered here: https://www.lynda.com/Scala-tutorials/Scala-Essential-Training-Data-Science/559182-2.html and on an introductory section where the instructor is introducing collections, he issues these commands in the REPL (using Scala v2.11):
...ANSWER
Answered 2020-Feb-28 at 23:12Taking it in reverse, yes Scala 2.13 made Range
abstract when it was previously concrete. However there was never any need to use new
to create one because val myRange2 = Range(1, 101, 2)
will work just fine, so this is an error in the tutorial.
The to
method returns the type Range.Inclusive
which is why this is printed by REPL. This is a subtype of Range
so it has all the methods of Range
and can be used wherever a Range
can be used.
new Range
returns Range
because it is explicitly calling the constructor so it must return Range
.
Note that if you do use Range(1, 101, 2)
this will return Range
in 2.12 and Range.Exclusive
in 2.13.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install scala-tutorials
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page