> and understand there's Array#any?. This is a misconception, `Array#any?` does not check if the array is empty, but if there is a true-ish value in the array: ```ruby irb(main):001:0> [false, nil].any? => false ``` This is d...herwinw (Herwin Quarantainenet)
You can do that with #tap. A very stupid example: ```ruby array = [true] res = array.to_a.tap do |obj| if obj[0] obj.replace([['true', :val]]) else obj.replace([['false', :val]]) end end.to_a.to_h p res ``` ...herwinw (Herwin Quarantainenet)
I can't say the usage of `bittest?` is directly clear to me. Does it test if resulting integer is not equal to `0`? And would we have to use it this way? ```ruby if (n & 0b10100000).bittest? ``` I think a name like `Integer#binar...herwinw (Herwin Quarantainenet)
The concrete use case that I got was that I wanted to replace all trailing whitespace, but leave tabs/newlines etc untouched. The current code looks like this: ```ruby newstr = str.sub(/ +$/, '') ``` I tried to see if there was a...herwinw (Herwin Quarantainenet)
`String#strip` and related methods have a hardcoded match on whitespace, defined as "null, horizontal tab, line feed, vertical tab, form feed, carriage return, space". It would be nice to allow a parameter to specify the characters you w...herwinw (Herwin Quarantainenet)
I don't really see how this would be any different from `match?` Beside that, the semantics are a bit ambiguous. `"foo".sub(/bar/, 'x')` does work, it just doesn't replace anything because there is no match for the regex. So would `su...herwinw (Herwin Quarantainenet)