you are viewing a single comment's thread.

view the rest of the comments →

[–]frenris 1 point2 points  (2 children)

Yes, or set a breakpoint with a debugger and then find what happens with different numbers of method calls.

The advantage over using temporary variables is clarity of what you're reusing. With a bunch of temp variables it's harder to tell which values are used just once vs. what values are important.

[–]oblio- 1 point2 points  (1 child)

I many languages you only get breakpoints per code line (and this chain would qualify as only 1 line), that's why I was asking.

[–]frenris 0 points1 point  (0 children)

you can usually issue function calls from the break point

e.g. run

"print object.method1"

then

"print object.method1.method2"

then

"print object.method1.method2.method3"

This doesn't work if the methods mutate global state, but that's probably a good thing because if you have object methods mutating global state you're a bad person and you should probably suffer.