title: Questions about Solidity call function
body: <p>I'm studying about <code>call</code> function in solidity and got stuck. Below is the code I'm working on and what I want is to call <code>bar</code> function from <code>Foo</code> in <code>Loo</code> contract.</p>
  <pre><code>// SPDX-License-Identifier: GPL-3.0
  pragma solidity ^0.8.0;
  
  contract Loo {
      Foo foo;
  
      function callWithInstance(address payable _t, uint a, uint b) public payable returns(uint) {
          foo = Foo(_t);
          return foo.bar(a,b);
      }
      
      function callWithEncodeSignature(address _t, uint a, uint b) public returns(uint) {
         bytes memory data = abi.encodeWithSignature(&quot;bar(uint, uint)&quot;, a, b);
          (bool success, bytes memory returnData) = _t.call( data);
          require(success);
          uint c = abi.decode(returnData, (uint));
          return c;
      }
  
      function callWithEncode(address _t, uint a, uint b) public returns(uint) {
          (bool success, bytes memory returnData) = _t.call( bytes4(keccak256(&quot;bar(uint, uint)&quot;)), a, b);
          require(success);
          uint c = abi.decode(returnData, (uint));
          return c;
      }
      
  }
  
  contract Foo {
      function bar(uint a, uint b) public pure returns(uint) {
          return a+b;
      }
  }
  </code></pre>
  <ol>
  <li>I cannot find any advantages using <code>call</code> function instead of calling the function directly from contract instance. What is the advantage of using it?</li>
  <li>My <code>callWithEncodeSignature</code> fails to get pass the <code>require(success)</code>. I cannot find out the reason.</li>
  <li>My <code>callWithEncode</code> function gives &quot;TypeError: Wrong argument count for function call&quot;. What did I missed?</li>
  </ol>