title: Swift passing array to function with return
body: <p>I need this array</p>
  
  <pre><code>self.values.append(value)  
  </code></pre>
  
  <p>in order to append another array with the values from the array above^. Pretty much i need to pass one array to another function with the appended values.</p>
  
  <pre><code> func updateChartValues() -&gt; (LineChartDataSet) {
  
             self.recieveChartValues()
  
              var entries: [ChartDataEntry] = Array()
  
              for i in 0 ..&lt; values.count {
  
                  entries.append(ChartDataEntry(x: Double(i), y: Double(values[i]), data: UIImage(named: "icon", in: Bundle(for: self.classForCoder), compatibleWith: nil)))
  </code></pre>
  
  <p>How can I get these values that are appended from recieveChartValues() to updateChartValues? The main confusion is because they are appended from Firebase.</p>
  
  <pre><code>func recieveChartValues() {
  
          //Firebase Initialization
          var ref: FIRDatabaseReference!
          ref = FIRDatabase.database().reference()
  
          ref.child("general_room_index").observeSingleEvent(of: .value, with: {(snap) in
              print("error3")
  
  
  
              if let snaps = snap.value as? [Any]{
                  for val in snaps {
                      if let value = val as? Int{
                          self.values.append(value)
                          //print(self.values)
                      }
                  }
              }
  
          })
  
      }//retrive values func
  
  
  
  func updateChartValues() -&gt; (LineChartDataSet) {
  
         self.recieveChartValues()
  
          var entries: [ChartDataEntry] = Array()
  
          for i in 0 ..&lt; values.count {
  
              entries.append(ChartDataEntry(x: Double(i), y: Double(values[i]), data: UIImage(named: "icon", in: Bundle(for: self.classForCoder), compatibleWith: nil)))
  
              print("Enetrie ", entries)
  
  
  
          }
  
  
  
          self.dataSet = LineChartDataSet(values: entries, label: "Bullish vs. Bearish")
          self.dataSet.mode = LineChartDataSet.Mode.cubicBezier
  
  
          return dataSet
  
      }
  </code></pre>