My messages

Report a typo

You want to send messages, but you always have the same header and footer for them, and you don't want to repeat them every time you write a message. To achieve this, you can use implicit values for the header and footer. Since you can't have two separate implicit values of the same type, you need to use a tuple for the header, where the first element is "Hello" and the second element is "Nice to meet you". The footer can remain a simple string, "Good day".

You need to implement a send function that displays the message with the given header, text, and footer in the format: s"${header(0)}\n${header(1)}\n$text\n$footer". Don't forget to implement default header and footer.

Sample Input 1:

text

Sample Output 1:

Hello
Nice to meet you
text
Good day
Write a program in Scala 3
given defaultHeader: ??? = ???
given defaultFooter: ??? = ???

def send(text: String)(???): String =
s"${header(0)}\n${header(1)}\n$text\n$footer"
___

Create a free account to access the full topic