I am using Pharo 4. Suppose my objects already implemented nice equality and hash methods.
How do I visually compare two or N objects in different inspectors? With visually I mean a side by side comparison where I can look differences easily.
I tried allInstances but is becoming tedious after a while.
You might get inspired by looking at the diff browser you can choose when doing GLMBasicExamples open
. With Glamour you can easily create a custom browser to help you with this. The diff example itself is 15 lines of code:
| browser |
browser := GLMTabulator new.
browser
row: [:r | r column: #one; column: #two];
row: #diff.
browser transmit to: #one; andShow: [ :a |
a list
display: #first ].
browser transmit to: #two; andShow: [ :a |
a list
display: #second ].
browser transmit to: #diff; from: #one; from: #two; andShow: [ :a |
a diff
display: [ :one :two | {one asString . two asString}] ].
browser openOn: #(#(abc def ghi) #(abc xyz))
The diff view from glamour uses a DiffMorph to show differences. It needs a string representation of the two objects to compare
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With