title: Why is possible to write a function outside a class in Kotlin?
body: <p>I don't understand why is possible to write a function outside a class in Kotlin ? Is that a good practice ? </p>
  
  <p>For example, it's possible in Kotlin to write a function outside my <code>MainActivity</code> class :</p>
  
  <pre><code>fun hello(){}
  
  class MainActivity : AppCompatActivity() {
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
  
          hello()
      }
  }
  </code></pre>
  
  <p>In Java, this is impossible! That's not how an object-oriented language works normally, right?</p>
  
  <p>In the documentation, they talk of <strong>Local Functions</strong> for the classic function and <strong>Member Functions</strong> for the function defined inside a class or object but they don't explain when it's better to use one or the other.</p>