This repository has been archived on 2021-10-31. You can view files and clone it, but cannot push or open issues or pull requests.
ProgrammingInScala/First/src/main/scala/Hello.scala

34 lines
1.1 KiB
Scala

object Hello{
def main(args: Array[String]) = {
println("Hello, world")
//the args and predicates
println("Here are the args: ")
args.foreach((arg: String) => {
println(arg)
})
//objects
val big = new java.math.BigInteger("12345")
//arrays and [] (not recomended way to init, too verbose)
val lgrs = new Array[String](3)
lgrs(0) = "Greetings, and"
lgrs(1) = " welcome to"
lgrs(2) = " another LGR thing!"
for (i <- 0 to 2)
print(lgrs(i))
println()
// val means only no reassignation: the object CAN change
lgrs.update(2, lgrs(2) + " Let's go thrifting!" +
" [Branches.mp3 plays]") // "obj(args...) = something" == "obj.update(args..., something)
for (i <- 0.to(2)) // operators do not exist: operators are just methods.
print(lgrs.apply(i)) // "obj(args...)" == "obj.apply(args...)"
println()
// Recommended way to initialize arrays, == "Array.apply(args...)" (factory method)
val techmoans = Array("That's it for the moment, ", "and as always ", "thanks for watching! ", "[muppet clip]")
techmoans.foreach(techmoan => print(techmoan))
}
}