Computer scienceProgramming languagesScalaTypes and data structuresSpecial types

Unified types

Parse please

Report a typo

Write a function processData that takes a parameter of the type String | Int and performs different actions. If the parameter is a String, it should return the length of the string (converted to a string). If it is an Int, it should return even or odd depending on the number.

Sample Input 1:

8

Sample Output 1:

even
Write a program in Scala 3
def processData(data: String | Int): String =
??? // Write your code here
___

Create a free account to access the full topic