For `foo&.!empty?`, the result would be `nil` if `foo` is `nil`. This is not handled by the prototype. The alternatives mentionned so far look like this: `foo&.empty?&.!` `foo&.non&.empty?` `foo&.empty?&.not` `foo&.!(&:empty?)` ...MaxLap (Maxime Lapointe)
Thanks for the feedback. I updated the gist to have an example with arguments in the call: ```ruby puts A.new.!exists?(with_friends: true, skip_administrator: true) ``` This highlights some problems with the alternatives: * Ca...MaxLap (Maxime Lapointe)
I want to propose the following syntax: `foo.!bar`. I know it's already valid syntax, but please read on for details. When someone write a somewhat long line of code that is negated, the main way I've seen of doing it is: ``` must...MaxLap (Maxime Lapointe)
The following causes a memory leak. I left a commented line, both trigger an memory leak. I assume it's the same bug ``` require 'bigdecimal' BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, true) 10.times do |j| 100000.ti...MaxLap (Maxime Lapointe)
The following code gives the impression of a memory leak. ```ruby 10.times do 5000.times do Struct.new("A") Struct.send(:remove_const, :A) end GC.start puts `ps -o rss= -p #{$$}`.to_i end ``` ``` 27868 ...MaxLap (Maxime Lapointe)
In my mind, `get_and_set` is clear as it is in the order the operations are done. But if you want clearer, `get_then_set` puts emphasis on the order. Things like `exchange` and `swap` can sound like swapping the value between two k...MaxLap (Maxime Lapointe)
Problem is present in Ruby 3.2.2, 3.2.3, 3.3.0. Didn't check before. Put this in a file: ``` 10.times do 100000.times do Encoding.default_internal = nil end puts `ps -o rss= -p #{$$}`.to_i end ``` Result: ```...MaxLap (Maxime Lapointe)
And here is a similar problem, using only the block form (no calls to disable): ``` def check_speed(msg = nil) t1 = Time.now.to_f a = 0 1000000.times { |i| a += 10 } t2 = Time.now.to_f puts "#{t2-t1} - #{msg}" ...MaxLap (Maxime Lapointe)