title: Replacing variables names dynamically like string parts
body: <p>I'd like to optimise my code using a single function to process multiple possibilities depending on the situation: here it is different currencies.</p>
  
  <p>I know how to do it when I use strings with the <code>\(something)</code> syntax and I'd like something similar for variables.</p>
  
  <p>Here is my current situation for USD:</p>
  
  <pre><code>if WalletViewController.currencyUSD == true {
      if CurrentDifferenceFunctions.buyOrSellBitcoinUSD == 1 {
          if let lastBitcoinBuyPrice = UserDefaults.standard.object(forKey: "lastBitcoinBuyPrice\(currentCurrency)") as? Double {
              CurrentDifferenceFunctions.savedBitcoinPrice = lastBitcoinBuyPrice
          }
      } else if CurrentDifferenceFunctions.buyOrSellBitcoinUSD == 2 {
          if let lastBitcoinSellPrice = UserDefaults.standard.object(forKey: "lastBitcoinSellPrice\(currentCurrency)") as? Double {
              CurrentDifferenceFunctions.savedBitcoinPrice = lastBitcoinSellPrice
          }
      }
  }
  </code></pre>
  
  <p>How can I replace <code>USD</code> everytime it appears by another currency when needed and then be able to use the same function for different currencies? Would using arrays help here?</p>
  
  <p>I have a few dozens cryptos and as many currencies to process, any help would be gold!</p>
  
  <p>PS: I'm sorry about the redundant <code>WalletViewController.currencyUSD == true</code> but I like to keep my work literal until I fully understand the logic.</p>