Breaking News: Grepper is joining Read the official announcement!
Check it out

Constructing Lists Using :: and nil#

Sumit Rawal answered on May 23, 2023 Popularity 1/10 Helpfulness 1/10


More Related Answers

Constructing Lists Using :: and nil#


:: is a method, known as cons, which takes two arguments. The first argument is the head and is a single element. The second argument is a tail which is another List. nil is used to represent an empty List and is always used when constructing a List with ::.

This represents a List whose first element is x and the rest of the elements are the elements of another List xs. Hence, the fruitList in the code above could have also been defined as follows:

When using this method in code, we can actually remove the parenthesis (). 

Popularity 1/10 Helpfulness 1/10 Language scala
Source: Grepper
Tags: scala using
Link to this answer
Share Copy Link
Contributed on May 23 2023
Sumit Rawal
0 Answers  Avg Quality 2/10


Continue with Google

By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
Grepper Account Login Required

Oops, You will need to install Grepper and log-in to perform this action.