Skip to content

Elem constructor should not require using null to represent no-prefix #779

Description

@djbpitt

I don't know whether the follow issue reflects a suboptimal detail in the scala-xml API or whether my IDE is raising a spurious warning, and I'm inquiring here in case it's the former. Here are the details:

The Elem() constructor expects a string, representing a namespace prefix, as its first argument. An empty string throws an error:

IllegalArgumentException: prefix of zero length, use null instead

Using null works, but IntelliJ raises a warning:

Using Option is a safer alternative to null

I can suppress the warning in the IDE, but should I have to? That is, is there a reason that the prefix argument is String (with an implementation that does not accept an empty string) instead of Option[String]? Or is IntelliJ being incorrectly alarmist in a situation where the use of null is, in fact, properly idiomatic in Scala 3?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions