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 trial

iOS Swift Basics Swift Operators Working With Operators

demetri selmer
demetri selmer
521 Points

operators

not sure how to use the remained operator and the equal operator?

operators.swift
// Enter your code below
let value = 200
let divisor = 5

let someOperation = 20 + 400 % 10 / 2 - 15
let anotherOperation = 52 * 27 % 200 / 2 + 5

// Task 1 - Enter your code below

let results : Int =  value % divisor 

// Task 2 - Enter your code below

let isPerfectMultiple : Int = results != 0

2 Answers

demetri selmer
demetri selmer
521 Points

i did that and got this bummer Make sure that the value assigned to result is an operation using the remainder operator and not simply an Int value!

Michael Afanasiev
PLUS
Michael Afanasiev
Courses Plus Student 15,596 Points

Hi Demetri,

If you used the == you WILL get an error because you explicitly specified your constants to be of type Int (Also, there is no need to do that for this challenge.) and it cannot evaluate constants of type Bool.

Your code should basically look like so:

  // this evaluates to 0 because 5 can be equally divided in 200
let results = value % divisor 

 // checks if the result constant is equal to 0, means no remainder! ?          
let isPerfectMultiple = result == 0      

Hope this helps! Now go on to task number ✌️!