title: Unary operator '--' cannot be applied to an operand of type '@lvalue Int?' (aka '@lvalue Optional<Int>')
body: <p>I just updated my app's code to the latest version of Swift and I have this function:</p>
  
  <pre><code>func setupGraphDisplay() {
  
          //Use 7 days for graph - can use any number,
          //but labels and sample data are set up for 7 days
          //let noOfDays:Int = 7
  
          //1 - replace last day with today's actual data
          graphView.graphPoints[graphView.graphPoints.count-1] = counterView.counter
  
          //2 - indicate that the graph needs to be redrawn
          graphView.setNeedsDisplay()
  
          maxLabel.text = "\((graphView.graphPoints).max()!)"
          print((graphView.graphPoints).max()!)
  
          //3 - calculate average from graphPoints
          let average = graphView.graphPoints.reduce(0, +)
              / graphView.graphPoints.count
          averageWaterDrunk.text = "\(average)"
  
          //set up labels
          //day of week labels are set up in storyboard with tags
          //today is last day of the array need to go backwards
  
          //4 - get today's day number
          //let dateFormatter = NSDateFormatter()
          let calendar = Calendar.current
          let componentOptions:NSCalendar.Unit = .weekday
          let components = (calendar as NSCalendar).components(componentOptions,
              from: Date())
          var weekday = components.weekday
  
          let days = ["S", "S", "M", "T", "W", "T", "F"]
  
          //5 - set up the day name labels with correct day
          for i in (1...days.count).reversed() {
              if let labelView = graphView.viewWithTag(i) as? UILabel {
                  if weekday == 7 {
                      weekday = 0
                  }
                  labelView.text = days[(weekday--)!]
                  if weekday! &lt; 0 {
                      weekday = days.count - 1
                  }
              }
          }
      }
  </code></pre>
  
  <p>However I am getting an error message at the following line:</p>
  
  <pre><code>labelView.text = days[(weekday--)!]
  </code></pre>
  
  <p>Where Xcode is giving me the following error:</p>
  
  <pre><code>Unary operator '--' cannot be applied to an operand of type '@lvalue Int?' (aka '@lvalue Optional&lt;Int&gt;')
  </code></pre>
  
  <p>I tried searching online for answers but I still couldn't find anything that would help me fix this error. </p>
  
  <p>I was also curious what the error message exactly means by type <code>@lvalue Int (aka '@lvalue Optional&lt;Int&gt;')</code>? I have never seen this data type before and don't know how to solve the problem accordingly.</p>
  
  <p>Thanks in advance. </p>