79320322

Date: 2024-12-31 15:51:07
Score: 2.5
Natty:
Report link

I like GAel solution, but to come up with something different, If you're just starting with Scala 3, stick to the traditional main method (def main(args: Array[String]): Unit) or use the simpler @main approach with explicit arguments (@main def addNumbers(arg1: String, arg2: String): Unit).

If you want to access args as Array[String], you should define the main method without the @main annotation:

object AddNumbers {
  def main(args: Array[String]): Unit = {
    if (args.length < 2) {
      println("Please provide two numbers as arguments.")
    } else {
      println(args(0).toDouble + args(1).toDouble)
    }
  }
}

You can run this program with command-line arguments, and args will hold all arguments in an array.

Reasons:
  • RegEx Blacklisted phrase (2.5): Please provide
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @main
  • User mentioned (0): @main
Posted by: Ali Saberi