title: Scala - foreach is not a member of Int
body: <p>I'm fairly new to Scala and have to write a program which calculates the average of given List of Integers.</p>
  
  <p>However, I always get the error: </p>
  
  <blockquote>
    <p>foreach is not a member of Int. </p>
  </blockquote>
  
  <p>Does anybody of you know how to solve this? Here is my code:</p>
  
  <pre><code> var measureResults = List(100, 36, 54, 4, 22, 37, 86, 20, 3000)
  
   var averageResult = getAverage(measureResults)
  
   println(averageResult)
  
   def getAverage(measureResults: List[Int]): Double = {
      var entryList = listOfValidElements(measureResults)
      var average = entryList(0)
      for (element &lt;- average){
        average =+ 1 
        var trueAverage = average/length(entryList)
        return trueAverage
     }
   }
  </code></pre>