an class="va">a</span><span class="op">$</span><span class="fu">foo</span><span class="op">(</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> [1] "Calling class A `foo` method"</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> [1] "Self is a"</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> [1] "Next class is B"</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> [1] "Calling class B `foo` method"</span>
<span class="r-ou