I have just released
provides a Ruby-like
#=== operator for Visualworks Smalltalk.
#=== operator, or “case equals” as it is known, is used in Ruby
case statments and gives Ruby a lot of power in flexibly matching
Smalltalk doesn’t have (or need) a case statement, but this kind of
flexible matching can be useful in other situations. For example, I
#=== to match expected arguments in my
In this implementation, two objects are
=== if they are
===to an object if the block evaluates to
truewhen passed that object.
===to an object if the object is an instance of the class or one of its subclasses.
===to a number if that number is within the endpoints of the interval, including the endpoints.
If the optional Threequals-Regex package is loaded, a regular expression (
===to a string if the string matches the regex.
Be aware that
=== is asymmetric. The object that has specialized
#=== must be the receiver of the message. That is,
5) === 4 answers true, but
4 === (1 to: 5) answers false.
This seems like an arbitrary restriction, but consider the following:
Should this evaluate to
Threequals’ primary home is the Cincom Public Store Repository. Check there for the latest version. I’ve also put a snapshot of the current version of Threequals on GitHub. The Readme file on GitHub includes documentation of the API of Threequals if you’d like more information before diving in. I will also be submitting it for inclusion as a contributed package in a forthcoming Visualworks release.
Threequals was developed in VW 7.9.1, but is intended to be compatible with VW 7.7 and later.
Threequals is licensed under the MIT license.