title: How can I add a function extension for Fragment class in Kotlin?
body: <p>At present, I use Code B to display a message in a Fragment class, it works well.</p>
  
  <p>I hope to use Code A to do it, so I write Code C, but Code C is wrong, how can I fix Code C ? Thanks!</p>
  
  <p><strong>Code A</strong></p>
  
  <pre><code>import org.jetbrains.anko.*
  class UIFragmentCamera : Fragment() {
     private fun updateCameraUi() {
         toast("Hello")
      }
  }
  </code></pre>
  
  <p><strong>Code B</strong></p>
  
  <pre><code>import org.jetbrains.anko.*
  class UIFragmentCamera : Fragment() {
     private fun updateCameraUi() {
          requireContext().toast("Hello")
      }
  }
  </code></pre>
  
  <p><strong>Code C</strong></p>
  
  <pre><code>fun Fragment.toast(info:String) {
      requireActivity().toast(info)
  }
  </code></pre>