The ==(2)
method is a convenient replacement of x->x==2
. Could we also have !=(2)
?
EDIT: isa(Vector)
and ===(2)
would be nice, too.
I suppose that we cannot define this for the other types of comparisons like >=
or <=
right?
Sure we can. It just gets a bit confusing, since in <(2)
it might not be clear whether the 2 is the left or right argument.
The convention we decided on is that we do this kind of "auto-currying" for
predicate(subject, object)
functions taking two arguments and the curried form is
subject -> predicate(subject, object)
So in(collection)
means
item -> item in collection
By that rule <(b)
means a -> a < b
which makes sense since you read it as "less than b
".
Most helpful comment
The convention we decided on is that we do this kind of "auto-currying" for
functions taking two arguments and the curried form is
So
in(collection)
meansBy that rule
<(b)
meansa -> a < b
which makes sense since you read it as "less thanb
".