It should return false
or true
if all parameters are nil
thanks @serioga, my first approach is return nil
just for consistency and nil punning approach of the whole library
if the first parameter is not string it just return nil instead of raising NPE
example: (starts-with? nil "foobar") => nil
the confusion will come that caseless=
has very different semantics to the clojure =
operator
caseless=
only works with strings and clojure =
works with all types.
so, I consider does not return true
in case where (caseless= nil nil)
In fact right now in the latest published snapshot it returns nil
(`(caseless= nil nil) => nil`)
> In fact right now in the latest published snapshot it returns nil
(`(caseless= nil nil) => nil`)
maybe.
but for (caseless= nil "foobar")
I expect false
the analogy with starts-with?
looks wrong
> caseless=
only works with strings
it depends if it includes nilable or not
I don't see a reason to disallow nilable strings for comparison
Maybe caseless=
require options argument to define a behavour 🙂
Or maybe it should raise an exception for invalid arguments
well, returning nil
if arguments are invalid is like an exception.
usually I don't expect nils from predicates
how caseless=
works in case if some arg is int?
in same way as it is nil
take cara that at this moment, cuerdas handles the nil
or wrong input in a consistent manner around the library
if the main argument is not string, it just return nil
that in boolean comparisons is considered false
(boolean (caseless= nil "foobar")) => false
> take cara that at this moment, cuerdas handles the nil
or wrong input in a consistent manner around the library
in this case your initial question has no sense 🙂
The initial question is about the similarity of the caseless=
with =
and the possible confusion with (= nil nil) => true
and (caseless= nil nil) => nil
In any case thanks!
welcome 👌