Exercise: Processing User Information
Enhance your Kotlin proficiency by implementing and managing user data through precise rules and exception handling.
We'll cover the following
Problem statement
Implement the processUserInformation
function according to the following rules:
If the input
user
isnull
, return"Missing user information"
.If
name
fromuser
isnull
, return"Missing name"
.If
age
fromuser
isnull
, treat it as0
.If
email
fromuser
isnull
or contains a blank email address, return"Missing email"
.Otherwise, return information about the user in the following format:
"User $name is $age years old, email: $email"
.
Instructions
In the provided code, you are presented with the initial setup of data classes EmailAddress
and User
, along with the processUserInformation
function. Your task is to complete the implementation of the processUserInformation
function according to the specified rules and requirements.
The actual output when running the provided code should be as follows:
Get hands-on with 1400+ tech skills courses.