scala-io
scala-io copied to clipboard
relativize shouldn't return null
The following returns null:
val a = Path.fromString("/Users")
val b = Path.fromString("/etc")
a.relativize(b)
I think there's an implicit guarantee not to return null from a scala API. I think relativize should be either deprecated or fixed. Some suggestions:
- deprecate relativize and add relativizeOption (if backward compatibility is a must)
- change relativize to throw an exception if it's not possible to relativize (maybe add relativizeOption as well).
- change relativize to return an Option[Path]
I entirely agree. I'd never expect any of this API to return null
.
I absolutely agree with that. I will make the change.