0

I want to append this array

var rates  = [1.00, 0.98, 0.97, 0.90, 0.86, 0.84, 0.80, 0.79, 0.78, 0.77, 0.76, 0.76, 0.68, 0.66, 0.63, 0.61, 0.60, 0.60, 0.59, 0.57, 0.57, 0.55, 0.53, 0.53, 0.51, 0.51, 0.49, 0.48, 0.47, 0.46, 0.46, 0.46, 0.44, 0.44, 0.44, 0.43, 0.43, 0.43, 0.43, 0.43, 0.43, 0.43, 0.43, 0.43, 0.43, 0.43, 0.42, 0.42, 0.42, 0.42, 0.42, 0.42]

with this one

var ratesone  = [2.00, 1.98, 1.97, 0.99, 0.89]

under certain conditions This code does not work rates.append(ratesone) This is error message - I have Googled this for days without satisfactory answer

'Cannot convert value of type '[Double]' to expected argument type 'Double''

These are both Double arrays so why on earth is it trying to convert

koen
  • 5,383
  • 7
  • 50
  • 89
user3194306
  • 81
  • 1
  • 7

2 Answers2

1

Just join arrays using rates += ratesone

Wesley Gomes
  • 394
  • 3
  • 3
-1

You're trying to append the entire array as a single entity ([2.00, 1.98, 1.97, 0.99, 0.89], of type [Double]), into an array whose members are Double (not [Double]).

You're looking for Array.append(contentsOf:), or more popularly, the += operator.

Alexander
  • 59,041
  • 12
  • 98
  • 151