ruby-2.4

After Ruby 2.4 upgrade - error while trying to load the gem 'uglifier' (Bundler::GemRequireError)

跟風遠走 提交于 2019-12-12 07:45:03
问题 I've just upgraded my App to use Ruby 2.4.0 without any errors during the bundling process. When I try to start my server, however, I get the following error: There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError) Gem Load Error is: wrong argument type Class (expected Module) I found in other answers on this site that you need to add gem 'therubyracer' to your Gemfile, but I already have had that since the creation of my App. The latest version of NodeJS is

How does Ruby's max function order duplicates?

元气小坏坏 提交于 2019-12-01 04:10:31
I've been looking at the max method in Ruby's Enumerable mixin (v2.4.1). It's a fairly straightforward method, but how it orders items when duplicates are present is a bit confusing. For example: x = [1,2,3,4,5,6,7,8,9] x.max {|a, b| a%2 <=> b%2} => 1 10.times{|y| p x.max(y) {|a, b| a%2 <=> b%2}} [] [1] [1, 7] # why is 7 the next element after 1? [3, 1, 5] # why no more 7? [7, 3, 1, 5] # 7 is now first [9, 7, 3, 1, 5] [9, 7, 3, 1, 5, 6] [9, 7, 3, 1, 5, 4, 6] [9, 7, 3, 1, 5, 2, 4, 6] [9, 7, 5, 3, 1, 8, 6, 4, 2] # order has changed again (now seems more "natural") How is 7 chosen as the second

How does Ruby's max function order duplicates?

﹥>﹥吖頭↗ 提交于 2019-12-01 01:43:01
问题 I've been looking at the max method in Ruby's Enumerable mixin (v2.4.1). It's a fairly straightforward method, but how it orders items when duplicates are present is a bit confusing. For example: x = [1,2,3,4,5,6,7,8,9] x.max {|a, b| a%2 <=> b%2} => 1 10.times{|y| p x.max(y) {|a, b| a%2 <=> b%2}} [] [1] [1, 7] # why is 7 the next element after 1? [3, 1, 5] # why no more 7? [7, 3, 1, 5] # 7 is now first [9, 7, 3, 1, 5] [9, 7, 3, 1, 5, 6] [9, 7, 3, 1, 5, 4, 6] [9, 7, 3, 1, 5, 2, 4, 6] [9, 7, 5,