APIdock / Ruby
/
method

coerce

ruby latest stable - Class: Vector
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.

# File lib/matrix.rb, line 2121
 def coerce(other)
 case other
 when Numeric
 return Matrix::Scalar.new(other), self
 else
 raise TypeError, "#{self.class} can't be coerced into #{other.class}"
 end
 end

AltStyle によって変換されたページ (->オリジナル) /