Comment by chao-

Comment by chao- 21 hours ago

0 replies

I apologize for my lack of Smalltalk knowledge. As you can imagine, you can do similar in Ruby by defining ifTrue to accept a block, even adding ifTrue on other all objects and defining something similar:

  class TrueClass
    def ifTrue(&block) = block.call
  end

  class FalseClass
    def ifTrue(&block) = nil
  end

  class Object
    def ifTrue(&block) = block.call
  end
      
  class NilClass
    def ifTrue(&block) = nil
  end
If ck45's core complaint was that this is not baked into the language, I will agree that it is less convenient for lack of a default.