title: Why am I getting the optional type 'String' error for user input collected by readLine()? How do I force a user to only enter data types I want?
body: <p>I am trying to write a function isIncreasing that will return true when the numbers in a list are in increasing order. First, I wrote var input = readLine() to get user input and applied isIncreasing directly to input. I received the error: value of optional type 'String?' not unwrapped; did you mean to use '!' or '?'? In order to mute this error, I decided to apply the isIncreasing function only if the program knows for sure that input is an array of integers. However, even after I wrote the lines that convert user input into an array of integers, I still get the same error.</p>
  
  <pre><code>var result: Bool = true
  
  func isIncreasing(_ num: [Int]) -&gt; Bool{
      for i in num{
          if(num[i] &lt; num[i + 1]){
              result = true
          }
          else{
              result = false
          }
      }
      return result
  }
  
  print("Type in a list of integers")
  var input = readLine()
  
  if (type(of: input) == type(of: "val")){ //changing types into [Int] to get rid of the optional type 'String' error
      var arg = [Int]()
      for element in input.characters
      //I am still gtting the error: swift:20:20: error: value of optional type 'String?' not unwrapped; did you mean to use '!' or '?'?
      {
          arg.append(Int(String(element))!)
      }
      isIncreasing(arg)
  }
  //var arg: [Int] = Array(input).map { String($0).toInt()! }
  </code></pre>