What the difference between List.empty, List() and new List()? When should I use which?
What the difference between List.empty , List() and new List() ? When should I
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First of all,
new List()won’t work, since theListclass is abstract. The other two options are defined as follows in theListobject:I.e., they’re essentially equivalent, so it’s mostly a matter of style. I prefer to use
emptybecause I find it clearer, and it cuts down on parentheses.