coerce(other)
public
The coerce method provides support for Ruby type coercion. This coercion
mechanism is used by Ruby to handle
mixed-type numeric operations: it is intended to find a compatible common
type between the two operands of the operator. See also Numeric#coerce.
Show source
def coerce(other)
case other
when Numeric
return Scalar.new(other), self
else
raise TypeError, "#{self.class} can't be coerced into #{other.class}"
end
end