Start learning free

LESSON 40 OF 348 · FUNCTIONS I

Exercise: Create Function with Parameters in Scala in Scala

Practice

We've written this code:

def mainFunction(): Unit = {
	println("My name is Andy")
	println("I code in Python")
	println("I have a dog")

	println("My name is Mike")
	println("I code in Java")
	println("I have a cat")

	println("My name is Sarah")
	println("I code in Scala")
	println("I have a parrot")
}

Write the same code in a better way by creating and calling a function with parameters printMessages()

STEP 1 OF 2
    Ctrl + Enter to check

    Exercise Create Function With Parameters in Scala

    Keep going with ScalaAbout 340 step-by-step lessons, from your first line of code to coding interviews. Free to start.
    Start learning free