Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Triple colon Scala

Tags:

scala

I'm trying to pick up some scala. Reading through examples I came across this impossible-to-google nugget:

case 3 => l ::: List(3) 

What does the triple colon accomplish?

like image 423
providence Avatar asked Oct 01 '11 15:10

providence


People also ask

What does double colon mean in Scala?

The double colon ( :: ) is the cons operator; x represents the head of the list, and xs the tail.

What is colon in Scala?

because the colon colon method :: adds an element to the front of a list.

What does ++ mean in Scala?

++= can mean two different things in Scala: 1: Invoke the ++= method. In your example with flatMap , the ++= method of Builder takes another collection and adds its elements into the builder. Many of the other mutable collections in the Scala collections library define a similiar ++= method.

What does ::: mean in Scala?

The ::: operator in Scala is used to concatenate two or more lists. Then it returns the concatenated list. Example 1: Scala.

What is the use of colon colon method in Scala?

In Scala almost anything can be a name a method and just like foo.bar (i) is calling the method bar on object foo with i as argument, foo.:: (i) is calling the colon colon method on object foo with i as an argument. Usually this is used as infix notation operator (in scala any method can be used as an operator).

What is the use of colon(I) in Scala?

(i) is calling the colon colon method on object foo with i as an argument. Usually this is used as infix notation operator (in scala any method can be used as an operator). Methods who end in a colon are special in Scala, they are right associative which mean they stick to their right hand argument Is Scala an easy programming language?

What do double colons(::) mean in Scala programming language?

What do double colons (::) mean in the Scala programming language? - Quora What do double colons (::) mean in the Scala programming language? :: doesn’t mean anything in general.

What is the beauty of the Scala ternary operator syntax?

The beauty of this is (a) it’s just the normal if/else syntax, so you don’t have to remember something else, and (b) it’s easy to read. To show a more real-world example, here’s an example of how you can use the Scala ternary operator syntax on the right hand side of the equation:


1 Answers

Concatenates two lists - javadoc

like image 95
gkamal Avatar answered Sep 18 '22 23:09

gkamal