title: Searching through map using user input does not work
body: <p>This is what I need;</p>
  
  <p>The user inputs a key value and a number; For instance "SK1 > 34"</p>
  
  <p>The system then uses the key value from this to search through a map list called "mapdata". This is a "Map(String, List[Int])"</p>
  
  <p>This value is returned with only the last digit.</p>
  
  <p>However the problem I have is that when the system uses the key value to search the map, it fails to find it, even though the key value inputted is in the map.</p>
  
  <p>If I change the user stackCost to direct entering "SK1" then it works. This shows me the problem is in finding "stockValue" even though my test shows it is searching for SK1.</p>
  
  <p>Here is my current code;</p>
  
  <pre><code>def addNewStock =
    {
      println("Enter stock as *SK1* &gt; AMOUNT(8) and the stock level will be taken from the stocks*")
      print("Enter new Stock &gt; ")
      val key = readLine()
      var result = key.split(";").map(_ split "&gt;") collect { case Array(k, v) =&gt; (k, v) } toMap
  
      println ("Data entered into file " + result)
      //String.valueOf(
      var stockValue = String.valueOf(result.head._1)
      var stockCost = mapdata.get(stockValue)
  
      println("This is the stock value " + stockValue)
      println("This is the stock cost " + stockCost)
  
    }
  </code></pre>
  
  <p>mapdata that is being queried;</p>
  
  <pre><code>SK1, 9, 7, 2, 0, 7, 3, 7, 9, 1, 2, 8, 1, 9, 6, 5, 3, 2, 2, 7, 2, 8, 5, 4, 5, 1, 6, 5, 2, 4, 1
  SK2, 0, 7, 6, 3, 3, 3, 1, 6, 9, 2, 9, 7, 8, 7, 3, 6, 3, 5, 5, 2, 9, 7, 3, 4, 6, 3, 4, 3, 4, 1
  SK4, 2, 9, 5, 7, 0, 8, 6, 6, 7, 9, 0, 1, 3, 1, 6, 0, 0, 1, 3, 8, 5, 4, 0, 9, 7, 1, 4, 5, 2, 8
  SK5, 2, 6, 8, 0, 3, 5, 5, 2, 5, 9, 4, 5, 3, 5, 7, 8, 8, 2, 5, 9, 3, 8, 6, 7, 8, 7, 4, 1, 2, 3
  SK6, 2, 7, 5, 9, 1, 9, 8, 4, 1, 7, 3, 7, 0, 8, 4, 5, 9, 2, 4, 4, 8, 7, 9, 2, 2, 7, 9, 1, 6, 9
  SK7, 6, 9, 5, 0, 0, 0, 0, 5, 8, 3, 8, 7, 1, 9, 6, 1, 5, 3, 4, 7, 9, 5, 5, 9, 1, 4, 4, 0, 2, 0
  SK8, 2, 8, 8, 3, 1, 1, 0, 8, 5, 9, 0, 3, 1, 6, 8, 7, 9, 6, 7, 7, 0, 9, 5, 2, 5, 0, 2, 1, 8, 6
  SK9, 7, 1, 8, 8, 4, 4, 2, 2, 7, 4, 0, 6, 9, 5, 5, 4, 9, 1, 8, 6, 3, 4, 8, 2, 7, 9, 7, 2, 6, 6
  </code></pre>
  
  <p>EDITS***</p>
  
  <pre><code>var testing = result.toList
  var stockValue = String.valueOf(result.head._1)
  var stockCost = mapdata.get(stockValue).toList
  var stockCheck = stockCost.map(_.lastOption.getOrElse(0))
  var result2 = testing ::: stockCheck
  </code></pre>