Fork me on GitHub
#funcool
<
2016-09-18
>
serioga08:09:04

It should return false or true if all parameters are nil

niwinz09:09:12

thanks @serioga, my first approach is return nil

niwinz09:09:25

just for consistency and nil punning approach of the whole library

niwinz09:09:46

if the first parameter is not string it just return nil instead of raising NPE

niwinz09:09:21

example: (starts-with? nil "foobar") => nil

niwinz09:09:00

the confusion will come that caseless= has very different semantics to the clojure = operator

niwinz09:09:21

caseless= only works with strings and clojure = works with all types.

niwinz09:09:48

so, I consider does not return true in case where (caseless= nil nil)

niwinz09:09:23

In fact right now in the latest published snapshot it returns nil (`(caseless= nil nil) => nil`)

serioga09:09:05

> 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

serioga09:09:03

> 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

serioga09:09:03

Maybe caseless= require options argument to define a behavour 🙂

serioga09:09:10

Or maybe it should raise an exception for invalid arguments

serioga09:09:57

well, returning nil if arguments are invalid is like an exception. usually I don't expect nils from predicates

serioga09:09:51

how caseless= works in case if some arg is int?

niwinz09:09:59

in same way as it is nil

niwinz09:09:13

take cara that at this moment, cuerdas handles the nil or wrong input in a consistent manner around the library

niwinz09:09:32

if the main argument is not string, it just return nil

niwinz10:09:17

that in boolean comparisons is considered false

niwinz10:09:46

(boolean (caseless= nil "foobar")) => false

serioga10:09:29

> 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 🙂

niwinz10:09:57

The initial question is about the similarity of the caseless= with = and the possible confusion with (= nil nil) => true and (caseless= nil nil) => nil

niwinz10:09:39

In any case thanks!

serioga10:09:33

welcome 👌