Skip to content

Instantly share code, notes, and snippets.

@TheElectronWill
Last active August 7, 2019 13:49
Show Gist options
  • Select an option

  • Save TheElectronWill/5e45d2009eccd8101937bbf7b59abd5c to your computer and use it in GitHub Desktop.

Select an option

Save TheElectronWill/5e45d2009eccd8101937bbf7b59abd5c to your computer and use it in GitHub Desktop.
Pling Plang Plong! A small programming challenge to test Dotty (Scala 3) new "main methods" feature
@main def challenge(x: Int) = {
val str = Map(3 -> "Pling", 5 -> "Plang", 7 -> "Plong")
.filter((factor, name) => x % factor == 0)
.values
.mkString
println(if (str.nonEmpty) str else x)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment