Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKen Okiebisu
9,673 PointsKeep getting errors on the Ints and operands
swift_lint.swift:8:52: error: binary operator '*' cannot be applied to operands of type '[Int]' and 'Int' for multiplier in results { results.append(results * 6) } ~~~~~~~ ^ ~ swift_lint.swift:8:52: note: expected an argument list of type '(Int, Int)' for multiplier in results { results.append(results * 6) } ^ I keep getting these errors... can someone please give me a solution to this problem?
// Enter your code below
var results: [Int] = [1,2,3,4,5,6,7,8,9,10]
for multiplier in results { results.append(results * 6) }
2 Answers
Anthony Lafont
17,075 PointsHi Kenichi,
In this challenge, you're multiplying an array of ints ( [Int]) with a simple Int (6). The compiler can't handle that and this is why Xcode is complaining that way.
So the best way to solve the problem is to create a for in loop from the number 1 to the number 10 instead of changing the Array result and to append the multiplier of the loop times 6.
Here is my code:
var results: [Int] = []
for multiplier in 1...10 {
results.append(multiplier * 6)
}
Anthony
Ken Okiebisu
9,673 PointsThank you for the reply! I will be needing some more practice but i've somehow managed to understand this question! Thanks for the help!