title: Kotlin: Function declaration must have a name
body: <p>Aim of the code: Class Pair can print out Product name and quantity, Product name stored in Class Product</p>
  
  <pre><code>class Pair&lt;T, U&gt;(var product: Product, var quantity: Int) {
      for ( (product,quantity) in productAndQuantityList) {
          println("Name: ${product.productName}")
          println("Quantity: $quantity")
      }
  }
  </code></pre>
  
  <p>Above Error:(2, 9) Kotlin: Expecting member declaration
  Error:(2, 57) Kotlin: Function declaration must have a name</p>
  
  <pre><code>class ShoppingCart{
      private val productAndQuantityList = mutableListOf&lt;Pair&lt;Product,Int&gt; &gt;()
  ...
  }
  
  open class Product(
      val productName: String,
      var basePrice: Double,
      open val salesPrice: Double,
      val description: String) {
  ...}
  </code></pre>
  
  <hr>
  
  <ol>
  <li>may i know how to change my code?</li>
  <li> after class Pair was suggested by Compiler, but should i fill in anything?</li>
  <li>Which topic should i work for, to avoid the same errors again?</li>
  </ol>
  
  <p>Thanks!</p>