Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is ??? a valid symbol or operator in scala

Tags:

scala

I have seen the symbol

???

used in scala code, i however don't know if it's meant to be pseudo code or actual scala code, but my eclipse IDE for scala doesn't flag it and the eclipse worksheet actually evaluates it. I haven't been able to find anything via google search. Any help will be appreciated. Thanks

like image 796
SamAko Avatar asked Sep 21 '13 18:09

SamAko


People also ask

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 is the difference between :: and #:: In Scala What is the difference between ::: and in Scala?

In general: :: - adds an element at the beginning of a list and returns a list with the added element. ::: - concatenates two lists and returns the concatenated list.


2 Answers

Yes, this is a valid identifier.

Since Scala 2.10, there is a ??? method in Predef which simply throws a NotImplementedError.

def ??? : Nothing = throw new NotImplementedError

This is intended to be used for quickly sketching the skeleton of some code, leaving the implementations of methods for later, for example:

class Foo[A](a: A) {

  def flatMap[B](f: A => Foo[B]): Foo[B] = ???

}

Because it has a type of Nothing (which is a subtype of every other type), it will type-check in place of any value, allowing you to compile the incomplete code without errors. It's often seen in exercises, where the solution needs to be written in place of ???.

like image 164
Ben James Avatar answered Oct 21 '22 00:10

Ben James


To search for method names that are ASCII or unicode strings:


SO search: https://stackoverflow.com/search?q=[scala]+%22%3F%3F%3F%22

finds this thread Scala and Python's pass


scalex covers scala 2.9.1 and scalaz 6.0 http://scalex.org/?q=%3C%3A%3C

like image 32
Gene T Avatar answered Oct 20 '22 23:10

Gene T