João Costa @JD557@blog.joaocosta.eu Follow

Portuguese software engineer at Kevel.

My instance is running on a small server so please #nobot

Web

https://www.joaocosta.eu/

GitHub

https://github.com/JD557

Twitter

https://twitter.com/JD557

Itch.io

https://jd557.itch.io

  • Notes
  • Articles 6
  • Followers 41
  • Following 57
João Costa's avatar
João Costa
@JD557@blog.joaocosta.eu

I've been working a bit with Clojure, and found their concept of truthy/falsy values quite refreshing for a dynamic language: Only false and nil are considered falsy values, everything else is truthy.

None of that confusion of "Is 0 true or false? What about the string "0"? What about empty strings and empty lists?".

Maybe this will bite me in the future, but so far it looks like a good decision. 🙂

On that note, I've also learned that Java's Boolean actually provide (now deprecated) constructors that break reference equality (and in turn break Clojure's checks).

Namely new java.lang.Boolean("true") eq new java.lang.Boolean("true") is false while the recommended alternative java.lang.Boolean.valueOf("true") eq java.lang.Boolean.valueOf("true") is true.

I guess it makes some sense, but I always thought that there was no public Boolean constructor. 😅

  • permalink
  • interact from your instance
  • 5 months ago
Powered by microblog.pub 2.0.0+dev (source code) and the ActivityPub protocol. Admin.