scala-io icon indicating copy to clipboard operation
scala-io copied to clipboard

relativize shouldn't return null

Open johnomalley opened this issue 11 years ago • 2 comments

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]

johnomalley avatar Oct 12 '13 16:10 johnomalley

I entirely agree. I'd never expect any of this API to return null.

dcsobral avatar Oct 12 '13 16:10 dcsobral

I absolutely agree with that. I will make the change.

jesseeichar avatar Oct 14 '13 11:10 jesseeichar