-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Description
Considering #871,
I’ve been really surprised to find that OptionIdOps.some actually allows constructing Some(null) with no issues.
You can write:
val s: String = null
val o = s.some // is Some(null)However, should we allow users to do that?
It’s a really bad practice to construct Some(null), as this defeats the purpose of Option and breaks a lot of code.
People use Cats as an example for their own projects, and, I think, we should not promote allowing the construction of Some(null).
I propose that we deprecate OptionIdOps.some and introduce OptionIdOps.option as a safe alternative:
def option: Option[A] = Option(a)Alternatively, we could roll back OptionIdOps.some to its original null-safe state.
Metadata
Metadata
Assignees
Labels
No labels