Modulinos: Difference between revisions

added Scala
(→‎{{header|Python}}: Added parentheses to print so that the code samples will also work in Python 3.)
(added Scala)
Line 1,083:
print("Life means %s." % meaning_of_life())
print("Death means invisible scary skeletons.")</lang>
 
=={{header|Scala}}==
 
Note: Either the current directory (.) must be in the CLASSPATH environment variable, or the CLASSPATH should not be set.
 
~/.profile:
 
<lang sh># Scala
export CLASSPATH=$CLASSPATH:.</lang>
 
or
 
~/.profile:
 
(empty)
 
Example:
 
<lang sh>$ scala ScriptedMain.scala
Main: The meaning of life is 42
$ scalac ScriptedMain.scala Test.scala
$ scala Test
Test: The meaning of life is 42</lang>
 
ScriptedMain.scala:
 
Note the omission of shebangs. scalac refuses to compile code with shebangs.
 
<lang scala>object ScriptedMain {
val meaningOfLife = 42
 
def main(args: Array[String]) {
println("Main: The meaning of life is " + meaningOfLife)
}
}</lang>
 
Test.scala:
 
<lang scala>object Test {
def main(args: Array[String]) {
println("Test: The meaning of life is " + ScriptedMain.meaningOfLife)
}
}</lang>
 
=={{header|Smalltalk}}==
Anonymous user