title: Kotlin: pass class type used in filterIsInstance in a function
body: <p>I have written a function in kotlin</p>
  
  <pre><code>private fun mapBasketToTeam(basketIter: GenericBasket) {
          val fruitBasket = basketIter.basketTypeMap.getOrDefault(BasketType.FRUIT, listOf())
                  .filterIsInstance&lt;FruitBasket&gt;()
          val groceryBasket = basketIter.basketTypeMap.getOrDefault(BasketType.GROCERY, listOf())
                  .filterIsInstance&lt;GroceryBasket&gt;()
  }
  </code></pre>
  
  <p>Now I want to simplify it by creating a new function which takes type of class as <code>GroceryBasket</code> or <code>FruitBasket</code> and returns me <code>List&lt;GroceryBasket&gt;</code> or <code>List&lt;FruitBasket&gt;</code> respectively. So that there will be no duplication of same code in two lines.</p>
  
  <p>Is there any way to pass the class type to the function which can be then passed to <code>filterIsInstance</code>?</p>