diff options
author | Jeremy Daer <jeremydaer@gmail.com> | 2016-04-18 22:46:29 -0700 |
---|---|---|
committer | Jeremy Daer <jeremydaer@gmail.com> | 2016-04-18 22:53:20 -0700 |
commit | 7ad4690b2149fbb23faa179c21698b92ff383c73 (patch) | |
tree | 1206697be3e452ec423027a05fade291d9f50dc8 /actioncable/lib/action_cable/server | |
parent | f2f2d64429c674a9134bfd011995c30c6cc34dab (diff) | |
download | rails-7ad4690b2149fbb23faa179c21698b92ff383c73.tar.gz rails-7ad4690b2149fbb23faa179c21698b92ff383c73.tar.bz2 rails-7ad4690b2149fbb23faa179c21698b92ff383c73.zip |
Ruby 2.4: compat with new Array#sum
Ruby 2.4 introduces `Array#sum`, but it only supports numeric elements,
breaking our `Enumerable#sum` which supports arbitrary `Object#+`.
To fix, override `Array#sum` with our compatible implementation.
Native Ruby 2.4:
%w[ a b ].sum
# => TypeError: String can't be coerced into Fixnum
With `Enumerable#sum` shim:
%w[ a b ].sum
# => 'ab'
We tried shimming the fast path and falling back to the compatible path
if it fails, but that ends up slower even in simple causes due to the cost
of exception handling. Our only choice is to override the native `Array#sum`
with our `Enumerable#sum`.
Diffstat (limited to 'actioncable/lib/action_cable/server')
0 files changed, 0 insertions, 0 deletions