title: How to call a function from one module to another Magento 2
body: <p>I try to call a function from a module A to a module B
  here is the module A code </p>
  
  <pre><code>namespace A\Epayment\Model;
    class Etransactions
      {
        public function customPayment{
          return "test";
        }
  </code></pre>
  
  <p>and module b code</p>
  
  <pre><code>  namespace B\Payment\Controller\Index;
  
  class Payment extends \Magento\Framework\App\Action\Action
  {
      protected $_pageFactory;
      protected $_transaction;
  
      public function __construct(
          \Magento\Framework\App\Action\Context $context,
          \Magento\Framework\View\Result\PageFactory $pageFactory,
          \ETransactions\Epayment\Model\Etransactions $transaction
      )
      {
          $this-&gt;_pageFactory = $pageFactory;
          $this-&gt;_transaction = $transaction;
          parent::__construct($context);
      }
  
      public function execute()
      {
          echo "Hello World".PHP_EOL;
          $foo="a";
          echo $foo;
          echo $this-&gt;_transaction-&gt;customPayment();
          //echo $this-&gt;customPayment();
          echo $foo;
  
          exit;
      }
  }
  </code></pre>
  
  <p>this code return the "hello world", the first $foo, not the second and doesn't display any error</p>
  
  <p>can someone explain me where is my error ?</p>
  
  <p>EDIT: i didn't change anything but it works fine now. 
  thanks for the answers anyway</p>