3 ms·
Does Ruby convention follow Lisp in regards to methods ending in a question mark too? In Clojure and Scheme those methods should return an actual boolean value
by spacemanaki 15y ago
Does Ruby convention follow Lisp in regards to methods ending in a question mark too? In Clojure and Scheme those methods should return an actual boolean value and not truthy values or nil.
Compare `some` and `every?` in Clojure:
http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/every%3F http://clojure.github.com/clojure/clojure.core-api.html#cloj...
http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/some http://clojure.github.com/clojure/clojure.core-api.html#cloj...
And in Scheme `member` doesn't have a question mark for this reason, it returns the cdr of the list starting with the item if it's found.
It's a subtle point, and probably trips up newcomers, but I think it's useful, especially since the types of methods and functions in these languages are not as well broadcast as in statically typed languages.