daydreamer
daydreamer

Reputation: 91959

Scala: What does << mean?

I am very new to Scala. I have been asked to implement a feature so I am reading the codebase.

I see the following:

def * = (id ~: columns) <>(Account.<<.<<.<<.<<, (Account.unapply _).<<.<<.<<.<<)

...but I don't know what <<.<<. means, and Google did not gave me any correct result since it is a symbol.

What is this called?

Upvotes: 0

Views: 152

Answers (3)

Erik Kaplun
Erik Kaplun

Reputation: 38217

Load the code in an IDE (e.g. Scala IDE, Ensime or IDEA) and ask the IDE to go to the definition of that <<.

Upvotes: 2

Dennis
Dennis

Reputation: 2665

<< is just a normal method name in Scala. It seems that in your code you have an Account object defined with a method name <<. And that method returns another object that also has method <<.

You need to look at the help or implementation of the Account.<< method to see what it does. There is nothing special in Scala regarding << that you should be concerned. It is all in your implementation.

Upvotes: 5

Jay Bosamiya
Jay Bosamiya

Reputation: 3209

I am not very familiar with Scala, but since it looks like an operator, a quick Google search on "Scala operators" gives the Scala Operator Cheat Sheet

This has the following on the << operator:

<< BigInt Leftshift of BigInt
<< Byte
<< Char
<< Int
<< Long
<< Short
<< Buffer Send a message to this scriptable object.
<< BufferProxy Send a message to this scriptable object.
<< Map Send a message to this scriptable object.
<< MapProxy Send a message to this scriptable object.
<< Scriptable Send a message to this scriptable object.
<< Set Send a message to this scriptable object.
<< SetProxy Send a message to this scriptable object.
<< SynchronizedBuffer Send a message to this scriptable object.
<< SynchronizedMap Send a message to this scriptable object.
<< SynchronizedSet Send a message to this scriptable object.

As for the ., I think that would be a way of chaining things.

Hence, one might be able to think of this as the << operator chained multiple times into Account etc.

However, << might actually be a method defined somewhere instead of one of the above operators.

Upvotes: 1

Related Questions