Apart from making a nice symmetry with unary minus, why is unary plus operator defined on Numeric
class? Is there some practical value in it, except for causing confusion allowing writing things like ++i
(which, unlike most non-Rubyists would think, doesn't increment i
).
I can think of scenario where defining unary plus on a custom class could be useful (say if you're creating some sexy DSL), so being able to define it is ok, but why is it already defined on Ruby numbers?
Numeric
class though. – Agreed