Codetown ::: a software developer's community
object Hello { def main(args: Array[String]): Unit = {
println("Hello world.")
}
}
powerbookg4:tmp zemian$ scalac Hello.scala powerbookg4:tmp zemian$ scala Hello
Hello world.
Note that Scala main entry program is a "object" instead of "class". "object" in Scala is like a class that define a type, but it force it to be a singleton(only one instance), so it almost like "static" in Java. Your main entry in command line must be an object with the main method defined.
You may turn your source file into a script by enter a expression that invoke the main method on the end of the file, and then run it through "scala" instead of compiling it. For example:
object Hello { def main(args: Array[String]): Unit = {
println("Hello world.")
}
}
Hello.main(args)
powerbookg4:tmp zemian$ scala Hello.scala Hello world.
Note the difference. 1 no compile. 2 you give scala the script file name, not the type name!
Happy programming!
Tags:
Codetown is a social network. It's got blogs, forums, groups, personal pages and more! You might think of Codetown as a funky camper van with lots of compartments for your stuff and a great multimedia system, too! Best of all, Codetown has room for all of your friends.
Created by Michael Levin Dec 18, 2008 at 6:56pm. Last updated by Michael Levin May 4, 2018.
Check out the Codetown Jobs group.
Git 2.48 now supports the Meson build system, a modern alternative to the existing Makefile, Autoconf, and CMake-based systems. This change addresses limitations in IDE support and maintenance issues with older systems.
By Aditya KulkarniFluent Assertions, a well-known .NET library that allows expressive asserts in unit tests, has launched version 8 with a proprietary license in partnership with Xceed, replacing the existing Apache 2.0 licence. The new license allows free non-commercial use, but any commercial use will require a paid license. The move has been negatively received by the developer community.
By Edin KapićWeb accessibility is about making web content available to users with disabilities. Development teams can use the success criteria of the Web Content Accessibility Guidelines to improve accessibility and create an inclusive website.
By Ben LindersIan Thomas discusses VR software development, how to create immersive VR apps using familiar tools like React and JavaScript, making VR development accessible to Frontend Developers.w
By Ian ThomasApple's new Advanced Commerce API provides iOS developers more flexibility to dynamically manage large content catalogs, creator experiences, and subscriptions with optional add-ons, such as premium features. For a developer to be allowed to use the new API, they must request access to Apple.
By Sergio De Simone© 2025 Created by Michael Levin. Powered by