Erquint / giatros

A budding framework of bite-sized helper libraries for DRGTK.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nil_panic prevents inject/reduce from raising an exception

Erquint opened this issue · comments

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 required — 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}
commented

I think I remember reading that AriThMetic OpeRaToRs Are A Lie in mruby

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.