Com S 541 Lecture -*- Outline -*- * Other Means of Combination in Scala based on: scala.epfl.ch ** Programs are objects with a main method def main(args: Array[String]): Unit = ... ** Packages and compilation units ------------------------------------------ PACKAGES (AS IN JAVA, C#) Packages define: "a set of member classes, objects and packages" packages: cannot be used as values can be imported (import p.q;) can be selected (p.T) can have hidden (private) elements ------------------------------------------ ------------------------------------------ DIFFS FROM JAVA Multiple packages in a compilation unit: package p.q { /* ... */ } package p.r { /* ... */ } Imports ordered: later imports can names from earlier imports More implicit imports (ordered): 1. java.lang 2. scala 3. scala.Predef ------------------------------------------ ** Compound Data (skip) Both objects and instances of classes can contain multiple pieces of data They can also group multiple other entities (classes, traits, packages, etc.) ** Compound Actions (skip) ------------------------------------------ COMPOUND ACTIONS Conditionals: if (E1) E2 if (E3) E4 else E5 Loops: while (Test) Body do B2 while (T2) for (Enums) yield EV for (Enums2) Body3 Blocks: { S1 ... Sn } ------------------------------------------