Class meta-information can be derived from an object reference using getClass()
:
isInstanceOf[className]
is used to determine the if an object reference is an instance of given class:
Class meta-information can be retrieved by class name by using classOf[className]
:
A method's type signature comprises its name; the number, order, and types of its parameters, if any; and its result type.
A method's type signature comprises its name; the number, order, and types of its parameters, if any; and its result type. The type signature of a class, trait, or singleton object comprises its name, the type signatures of all of its members and constructors, and its declared inheritance and mixin relations.
In Java you declare a generic type within a <>
, in Scala []
is used:
val z: List[String] = "Do" :: "Re" :: "Mi" :: "Fa" :: "So" :: "La" :: "Te" :: "Do" :: Nil
Most of the time, Scala will infer the type and []
are optional:
val z = "Do" :: "Re" :: "Mi" :: "Fa" :: "So" :: "La" :: "Te" :: "Do" :: Nil //Infers that the list assigned to variable is of type List[String]
A trait can be declared containing a type, where a concrete implementer will satisfy the type:
The parameterless execute method has been deprecated and will be removed in a future version of ScalaTest. Please invoke execute with empty parens instead: execute().
The trap method is no longer needed for demos in the REPL, which now abreviates stack traces, and will be removed in a future version of ScalaTest