I have used match expression using yield in for loop but I am not getting desired result
val daysOfWeek = List("Mon","Tues","Wed","Thur","Fri","Sat","Sun")
val day = "Mon"
for (day <- daysOfWeek) yield
{
day match
{
case "Mon" => "is boring"
case otherDay => otherDay
print(day)
}
}
O/p of the above code is (TuesWedThurFriSatSun) but I want o/p like (is boringTuesWedThurFriSatSun)
How Can I achieve this ?
printis only executing in the case of other days. And also it is breaking the return type of all the expression toAny. What exactly do you want to do?