The Crystal programming language | http://crystal-lang.org | Fund Crystal's development: http://is.gd/X7PRtI | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/
Origin::Vector3.nearly_equal? v1, v2
user code calling Origin::Util.nearly_equal? f1, f2, rel_tol, abs_tol
internal code isn't too bad I suppose
v1 =~ v2
Origin::Scalar.=~ v1, v2
extend self
def ===
=~
==
on two floats, let alone 2 aggregates of floats, so ==
calls out to =~
incase the user didn't use the more explicit approximation method, which would clearly be an error. The problem is, ==
must take exactly 1 receiver and 1 argument, so the defaults for rel_tol
and abs_tol
must be used in that case.
=~
symbol over ==
to begin with is because of this...the parser treats all =
suffixed method names as setters, and errors on arity overloading away from that.
=~
doesn't mean the usual to Crystal programmers.
nearly_equals?
def ==; {{ raise ... }; end
for vector types.
other
in there somewhere :)
def self.zero : self
new 0.0
end
def self.one : self
new 1.0
end
V2::ZERO
returns the same instance then you could use a lazily initialized class getter