Scala: Updating a field of an object in an Option

Viewed 69

What is idiomatic way of updating a field in an object inside a scala option? flag is a boolean field in item,and I just want to reverse its value:

val newOption = itemOption.map(item => item.copy(flag = !item.flag))

Is this correct way?

0 Answers
Related