Reputation: 1747
this code:
class B(d:Int,val b:Option[Int])
object A extends App {
val c=new B(1)
}
is wrong at line B(1)
, I have to give a value of b
, like
new B(1,Some(2))
I am studying slick, the example code is:
final class MessageTable1(tag: Tag) extends Table[Message](tag, "message") {
class Table is in file main\scala\slick\relational\RelationalProfile.scala line 119:
abstract class Table[T](_tableTag: Tag, _schemaName: Option[String], _tableName: String)
extends AbstractTable[T](_tableTag, _schemaName, _tableName)
So the _schemaName
have the type Option[String]
, but when the example code create Table
, it seems not pass a value to it, only give the other two parameters: tag
and "message"
, why?
Upvotes: 0
Views: 46
Reputation: 369458
Three lines down, you can see that Table
has an auxiliary constructor with two parameters of type Tag
and String
(note: no Option
here):
def this(_tableTag: Tag, _tableName: String) = this(_tableTag, None, _tableName)
This is the constructor that is called in the example code you showed, not the primary constructor.
You can also see the two constructors in the documentation.
Upvotes: 1