Scala’s Map and Set define a + operator that returns a copy of the data structure with a single element appended to it. The equivalent operator for Seq is denoted :+.
Is there any reason for this inconsistency?
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.
Map and Set has no concept of prepending (
+:) or appending (:+), since they are not ordered. To specify which one (appending or prepending) you use,:was added.Don’t get confused by the order of arguments, in scala if method ends with : it get’s applied in reverse order (not a.method(b) but b.method(a))