Hi,

Dan Schmidt writes:

# Hal Fulton writes:
#
# | I propose that the (pseudo) operator "in" (named as such) should
# | result in a call to include? "under the hood," i.e., x in y or
# | any arbitrary pair of objects x and y, should behave exactly the
# | same as y.include? x, returning true or false and making possible
# | syntax like: if node in binary_tree then ...
#
# After some thought, I like it too.

I kind of like it too--especially if it does it better than Python (-:

# Python has the construct 'x in y', and it is handy.  And Python's
# usually pretty convervative when it comes to adding extra syntax.
#
# Unfortunately, in Python, it only works when y is an array, not when
# it's a hash, which many people find confusing (especially since, for
# large sets, sets are often better represented by hashes than arrays).
# I see that Ruby already has an 'include?' method in all the right
# places, so this wouldn't be a problem.

I just had the following half-baked thought, so I haven't had a chance to
think this through, but it may stimulate better ideas....

Rather than hardwiring one particular case (i.e. "in"), it might be nicer
if this addition could be made more general so that it would work with
other cases of "pseudo-operator syntactic sugar aliasing" (or whatever you
generically call it), for instance by (say) prefixing them with a
distinguished symbol/token such as "<>in" or "<->in" (which in this case
was intended to iconographically/mnemonically suggestive/reminding of
swapping the normal "dot-order of things", and which prefix you could also
call the "pseudo-operator symbol"). This thing might be treated as a
method name that should be previously defined as an alias to the "real"
method.

Conrad Schneiker
(This note is unofficial and subject to improvement without notice.)