title: How to use a lambda instead of a kotlin interface
body: <p>I have a recycler view adapter in android. Part of my adapter class looks like this:</p>
  
  <pre><code>private lateinit var itemLongClick: ItemLongClick
  
  override fun onCreateViewHolder(parent: ViewGroup, a: Int): RecyclerAdapter.ViewHolder {
  
        // Define And Initialize The Custom View And Its Holder//
        val myView = LayoutInflater.from(parent.context).inflate(customLayout, parent, false)
        val viewHolder = ViewHolder(myView)
  
        // What Happens When A List Item Is Long Clicked//
        myView.setOnLongClickListener { view -&gt;
  
            // Differ Action To Class Instance//
            itemLongClick.longClicked(context, viewHolder.layoutPosition, view)
  
            // End Function//
            true
        }
  
        // Returns The Custom View//
        return viewHolder
  }
  
  fun setItemLongClick(itemLongClick: ItemLongClick) {
  
      // Sets The Value For this.itemLongClick//
      this.itemLongClick = itemLongClick
  }    
  </code></pre>
  
  <p>I created an interface tat looks like this:</p>
  
  <pre><code>interface ItemLongClick {
  
      // Function Declaration For When An Item Is Long Clicked//
      fun longClicked(context: Context, position: Int, view: View)
  }
  </code></pre>
  
  <p>Instead of writing my on long click code in the adapter class I want to differ it to the activity that is calling the adapter class. I know one way of doing this is to make a kotlin interface then call it in the other class like this</p>
  
  <pre><code>  userAdapter.setItemLongClick(object: ItemLongClick {
          override fun longClicked(context: Context, position: Int, view: View) {
  
          }
      })
  </code></pre>
  
  <p>But this looks messy. I know java interfaces work with SAM but I don't want to do that either. What I want is for the onLongClick to be a Lambda but I'm not sure how to set up a Kotlin lambda expression to make this work and I can't find a good example anywhere.</p>
  
  <p>Thanks in advance</p>