title: What are the differences between a companion object function and package level functions?
body: <p>Whats the difference between having a function on a companion object and having the function at package level?</p>
  <pre><code>class Foo {
  
      companion object {
          fun bar() = println(&quot;bar&quot;)
      }
  }
  
  fun bar() = println(&quot;bar&quot;)
  </code></pre>
  <p>You can call both pretty similar</p>
  <pre><code>class B {
  
      fun print() {
          Foo.bar()
      }
  
      fun print2() {
          bar()
      }
  }
  </code></pre>