nil_panic prevents inject/reduce from raising an exception
Erquint opened this issue · comments
Murad "Gness Erquint" Beybalaev commented
DRGTK arithmetic operators couldn't possibly be any more fake:
-> [1,2].inject(:+)
* EXCEPTION: * ERROR:
** method_missing: +
** instance: 1
** on class: Fixnum
** with modules: [Integral, NumericDeprecated, ValueType, Comparable, Kernel]
** with values: 1
** given args: [[2]]
** exception: can't define singleton
Log above is without nil_panic
.
With nil_panic
require
d — no exception is thrown and Array#Inject
/Array#Reduce
silently returns nil
.
This is not desired behavior.
Block overload still works with and without nil_panic
.
Examples:
[4, 20].reduce{|sum, summand| sum + summand}
array.inject{|product, factor| product + factor}
mooff commented
I think I remember reading that AriThMetic OpeRaToRs Are A Lie in mruby
Murad "Gness Erquint" Beybalaev commented
Hrrgm…
Not like I'm picking this back up but where was I with it..?
Think I remember some changes to later versions of DRGTK that made this issue obsolete but don't quote me on it.