AtomicScala / atomic-scala-corrections

Find out about or report corrections for the book "Atomic Scala"
http://www.atomicscala.com
6 stars 2 forks source link

Two Package declarations in one .scala file #42

Open sidnt opened 8 years ago

sidnt commented 8 years ago

on page 97, it's written: " You create your own package using the package keyword (this must be the first non-comment statement in the file) followed by the name of your package (all lowercase) "

This statement seems to be more advice than rule. The requirement of having package keyword as the first non-comment statement in the file seems dispensable. A source file having multiple package declarations, with the respective code in a pair of curly braces, seems to work fine.

Compilation of a source file with two package keywords (with their respective code) seems to create two folders, distributing the respective class files to them. The compiler doesn't complain if in the same source file, first a class is defined, then two packages are defined, all with their respective codes in curly braces.

Even package nesting seems to work, with the nesting scheme being manifested in the directory scheme created on the file system.

BruceEckel commented 8 years ago

Thanks for all the good feedback. Just wanted to let folks know I'm working on another project but will eventually circle around and fix all this.