[#108176] [Ruby master Bug#18679] Encoding::UndefinedConversionError: "\xE2" from ASCII-8BIT to UTF-8 — "taf2 (Todd Fisher)" <noreply@...>

Issue #18679 has been reported by taf2 (Todd Fisher).

8 messages 2022/04/05

[#108185] [Ruby master Feature#18683] Allow to create hashes with a specific capacity. — "byroot (Jean Boussier)" <noreply@...>

Issue #18683 has been reported by byroot (Jean Boussier).

13 messages 2022/04/06

[#108198] [Ruby master Feature#18685] Enumerator.product: Cartesian product of enumerators — "knu (Akinori MUSHA)" <noreply@...>

Issue #18685 has been reported by knu (Akinori MUSHA).

8 messages 2022/04/08

[#108201] [Ruby master Misc#18687] [ANN] Upgraded bugs.ruby-lang.org to Redmine 5.0 — "hsbt (Hiroshi SHIBATA)" <noreply@...>

Issue #18687 has been reported by hsbt (Hiroshi SHIBATA).

10 messages 2022/04/09

[#108216] [Ruby master Misc#18691] An option to run `make rbconfig.rb` in a different directory — "jaruga (Jun Aruga)" <noreply@...>

Issue #18691 has been reported by jaruga (Jun Aruga).

14 messages 2022/04/12

[#108225] [Ruby master Misc#18726] CI Error on c99 and c2x — "znz (Kazuhiro NISHIYAMA)" <noreply@...>

Issue #18726 has been reported by znz (Kazuhiro NISHIYAMA).

11 messages 2022/04/14

[#108235] [Ruby master Bug#18729] Method#owner and UnboundMethod#owner are incorrect after using Module#public/protected/private — "Eregon (Benoit Daloze)" <noreply@...>

Issue #18729 has been reported by Eregon (Benoit Daloze).

28 messages 2022/04/14

[#108237] [Ruby master Bug#18730] Double `return` event handling with different tracepoints — "hurricup (Alexandr Evstigneev)" <noreply@...>

Issue #18730 has been reported by hurricup (Alexandr Evstigneev).

8 messages 2022/04/14

[#108294] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces — sos4nt <noreply@...>

Issue #18743 has been reported by sos4nt (Stefan Schテシテ殕er).

20 messages 2022/04/19

[#108301] [Ruby master Bug#18744] I used Jazzy to generate the doc for my iOS library, but it showed me a bug — "zhaoxinqiang (marc steven)" <noreply@...>

Issue #18744 has been reported by zhaoxinqiang (marc steven).

8 messages 2022/04/20

[ruby-core:108253] [Ruby master Feature#18736] self-p for method chain

From: "aDAVISk (Akito Kawamura)" <noreply@...>
Date: 2022-04-15 09:03:03 UTC
List: ruby-core #108253
Issue #18736 has been reported by aDAVISk (Akito Kawamura).

----------------------------------------
Feature #18736: self-p for method chain
https://bugs.ruby-lang.org/issues/18736

* Author: aDAVISk (Akito Kawamura)
* Status: Open
* Priority: Normal
----------------------------------------
You may want to check object with `p` method at the middle of a method chain.
Here is my recomendation.
 
```ruby
class Object
  def sp(method=nil, *args, &block)
    if method
        Kernel.p self.public_send(method, *args, &block)
    elsif block_given?
        Kernel.p block.call(self)
    else
      Kernel.p self
    end
    return self
  end
end
```

Example of usage:
1) check itself in the middle of a method-call
```ruby
p [1,2,3].map{|x| x**2}.sp.map{|x| x**2}
```
- output
```
[1,4,9]
[1,16,81]
```
2) check its value in some string format
```ruby
[1,2,3].sp{|x| "my List = #{x}"}
```
- output
```
"my List = [1,2,3]"
```
3) check its sum with an initial value
```ruby
[1,2,3].sp(:sum,-10)
```
- output
```
-4
```
4) check its value with a `map` operation
```ruby
[1,2,3].sp(:map){|x| x**2}
```
- output
```
[1,4,9]
```
5) check its value connected in string
```ruby
[1,2,3].sp(:sum,""){|x| x.to_s}
```
- output
```
"123"
```

---
Your brush-up comments are welcomed. thx.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next