regex

Hi

re=/abc/i

"#{re}"

 \- which method is called on re to get this???
 \- which ways exist \(trace/log called methods\) to find this out?

thank you
Opti

Hi

re=/abc/i

"#{re}"

     - which method is called on re to get this???

To get what exactly? A string representation of re?

     - which ways exist (trace/log called methods) to find this out?

ruby --dump=parsetree

Might be helpful. 3.x offers a lot with respect to that i think. And there
is docu about it

···

Die Optimisten <inform@die-optimisten.net> schrieb am Fr., 12. Aug. 2022, 16:18:

thank you
Opti

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

Hi

How do I get a log of the methods being called when executing a method?

e.g.: puts var -> calls var.to_s

···

thank you
Opti

If only you would call 'ruby --help' once AND read .... It's all there
infront of your eyes

···

Die Optimisten <inform@die-optimisten.net> schrieb am Fr., 12. Aug. 2022, 16:42:

Hi

How do I get a log of the methods being called when executing a method?

e.g.: puts var -> calls var.to_s

> thank you
> Opti

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

Whenever you have:

"#{object}"

The `#to_s` method is called on the object, including Regular Expressions
(`Regexp` objects).

There is no way of tracing that. It is just a learnable fact about the Ruby
programming language.

Regards,

···

On Fri, Aug 12, 2022 at 10:18 AM Die Optimisten <inform@die-optimisten.net> wrote:

Hi

re=/abc/i

"#{re}"

     - which method is called on re to get this???
     - which ways exist (trace/log called methods) to find this out?

thank you
Opti

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

--
Andy Maleh

LinkedIn: https://www.linkedin.com/in/andymaleh
<https://www.linkedin.com/in/andymaleh&gt;
Blog: http://andymaleh.blogspot.com
GitHub: AndyObtiva (Andy Maleh) · GitHub
Twitter: @AndyObtiva <https://twitter.com/AndyObtiva&gt;

Whenever you have:

"#{object}"

The `#to_s` method is called on the object, including Regular Expressions

(`Regexp` objects).

There is no way of tracing that. It is just a learnable fact about the

Ruby programming language.

Regards,

That said, on further though, you could probably trace this by using the
Ruby [TracePoint](Class: TracePoint (Ruby 3.1.0)) feature,
which lets you trace the execution of all methods and output something to
indicate which method is executed.

Still, you should know the fact mentioned in my previous reply by heart if
you've learned Ruby properly from a good book.

Cheers,

···

On Fri, Aug 12, 2022 at 3:58 PM Andy Maleh <andy.am@gmail.com> wrote:

Whenever you have:

"#{object}"

The `#to_s` method is called on the object, including Regular Expressions
(`Regexp` objects).

There is no way of tracing that. It is just a learnable fact about the
Ruby programming language.

Regards,

On Fri, Aug 12, 2022 at 10:18 AM Die Optimisten <inform@die-optimisten.net> > wrote:

Hi

re=/abc/i

"#{re}"

     - which method is called on re to get this???
     - which ways exist (trace/log called methods) to find this out?

thank you
Opti

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

--
Andy Maleh

LinkedIn: https://www.linkedin.com/in/andymaleh
<https://www.linkedin.com/in/andymaleh&gt;
Blog: http://andymaleh.blogspot.com
GitHub: AndyObtiva (Andy Maleh) · GitHub
Twitter: @AndyObtiva <https://twitter.com/AndyObtiva&gt;

--
Andy Maleh

LinkedIn: https://www.linkedin.com/in/andymaleh
<https://www.linkedin.com/in/andymaleh&gt;
Blog: http://andymaleh.blogspot.com
GitHub: AndyObtiva (Andy Maleh) · GitHub
Twitter: @AndyObtiva <https://twitter.com/AndyObtiva&gt;

You actually can trace it with the --dump interpreter option

···

Andy Maleh <andy.am@gmail.com> schrieb am Fr., 12. Aug. 2022, 22:04: > > Whenever you have:

>
> ```ruby
> "#{object}"
> ```
>
> The `#to_s` method is called on the object, including Regular
Expressions (`Regexp` objects).
>
> There is no way of tracing that. It is just a learnable fact about the
Ruby programming language.
>
> Regards,

That said, on further though, you could probably trace this by using the
Ruby [TracePoint](Class: TracePoint (Ruby 3.1.0))
feature, which lets you trace the execution of all methods and output
something to indicate which method is executed.

Still, you should know the fact mentioned in my previous reply by heart if
you've learned Ruby properly from a good book.

Cheers,

On Fri, Aug 12, 2022 at 3:58 PM Andy Maleh <andy.am@gmail.com> wrote:

Whenever you have:

"#{object}"

The `#to_s` method is called on the object, including Regular Expressions
(`Regexp` objects).

There is no way of tracing that. It is just a learnable fact about the
Ruby programming language.

Regards,

On Fri, Aug 12, 2022 at 10:18 AM Die Optimisten < >> inform@die-optimisten.net> wrote:

Hi

re=/abc/i

"#{re}"

     - which method is called on re to get this???
     - which ways exist (trace/log called methods) to find this out?

thank you
Opti

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

--
Andy Maleh

LinkedIn: https://www.linkedin.com/in/andymaleh
<https://www.linkedin.com/in/andymaleh&gt;
Blog: http://andymaleh.blogspot.com
GitHub: AndyObtiva (Andy Maleh) · GitHub
Twitter: @AndyObtiva <https://twitter.com/AndyObtiva&gt;

--
Andy Maleh

LinkedIn: https://www.linkedin.com/in/andymaleh
<https://www.linkedin.com/in/andymaleh&gt;
Blog: http://andymaleh.blogspot.com
GitHub: AndyObtiva (Andy Maleh) · GitHub
Twitter: @AndyObtiva <https://twitter.com/AndyObtiva&gt;

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

It's also surprising that ruby -h doesn't output the same as --help.

That does NOT conform to Unix-rules; long and short options should
always do the same!

-> change --help this to -hh or --longhelp (or other...) - Any comments?

Opti

···

Am 12.08.22 um 23:02 schrieb Der Zernichter:

You actually can trace it with the --dump interpreter option

You actually can trace it with the --dump interpreter option

It's also surprising that ruby -h doesn't output the same as --help.

That does NOT conform to Unix-rules; long and short options should
always do the same!

Surprising though it is, Ruby does exactly what it says it does. It outputs a short useful convenient response when you do -h and ends with the helpful note:
> -h show this message, --help for more info

For most people, that's a useful result compared with pages of text that scroll by while you stick something else to paginate it.

I read many of your posts in the threads here, and I get the feeling that Ruby continues to surprise you in unwelcome ways. Thank you for sticking with Ruby (for whatever reason) and we're here to help with genuine problems you face. That said, getting into Ruby will be easier if you accept that Ruby does what the docs say rather than what someone expects (although most of the time, the two are the same). Given that Ruby is now 25 years old, it's unlikely that breaking changes will be introduced in a manner in which they deviate from the broadly pleasant experience that most Ruby developers have.

Best wishes,
Mohit.

···

On 2022-8-13 5:50 pm, Die Optimisten wrote:

Am 12.08.22 um 23:02 schrieb Der Zernichter: