Join GitHub today
Add array named setters #6979
This comment has been minimized.
This comment has been minimized.Show comment Hide comment
Except that it does not work for all cases: when the array is empty,
>> a =  =>  >> a[a.length - 1] = 'last!' IndexError: index -1 too small for array; minimum: 0 ... >> a[-1] = 'last!' IndexError: index -1 too small for array; minimum: 0
I personally disagree with the idea of adding similar helpers to Active Support, since these helpers are probably not going to be used internally by the framework (and possibly by most users). It looks like a method I'd have to look at the implementation to see what's going on. Anyway, thanks for the contribution @lexmag :)