Task
In this challenge, you had to create a function which prints the result of another function.
Solution
A skeleton of the function was already provided for you. Let’s look it over.
def arithmeticPrinter(f: (Int , Int) => Int, x: Int, y: Int) = {
}
The function name is arithmeticPrinter
and it has three parameters. The first parameter is another function f
which has two parameters of its own and returns an integer. The second parameter is an integer x
and the third parameter is an integer y
.
You had to write a line of code which would print the result of f
given that it was passed x
and y
as arguments.
print(f(x,y))
You can find the complete solution below:
You were required to write the code on line 2.
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy