--

But it turns out that this works in JavaScript indeed :D

Just check the code:

Boolean.prototype.ifTrue = function(p) { this.valueOf() && p() }

(1 < 2).ifTrue(() => console.log('hello')) // logs hello
(3 < 2).ifTrue(() => console.log('bye')) // does nothing

I never thought that it could work :) But it does! Thanks!

And thanks for spreading the love for Smalltalk, I do really believe that it is one of the languages that more have contributed to the advance of the software engineering itself.

I wrote my own story like you showing the greatness of smalltalk (some from different points of view, all valid). And, if you don’t mind, I’ll link yours back.

Thanks for sharing!

--

--

David Rodenas PhD
David Rodenas PhD

Written by David Rodenas PhD

Passionate software engineer & storyteller. Sharing knowledge to advance our skills. Join me on a journey of discovery in the world of software engineering.

Responses (1)