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 2.0 Basics Swift Operators Working With Operators

Michael Friedman
Michael Friedman
495 Points

Great job with the first task! In this task, we have two math operations. Without computing the values of those

I'm unclear on what I'm doing wrong. I don't recall being instructed on how to do this and at $600 a month this is becoming an expensive guessing game.

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 result = value % divisor
// Task 2 - Enter your code below
let isPerfectMultiple = result == 0
let isGreater = someOperation >= anotherOperation == 1
Michael Friedman
Michael Friedman
495 Points

I have tried assigning to a boolean value and that doesn't work.

5 Answers

anil rahman
anil rahman
7,786 Points
let isGreater = someOperation >= anotherOperation && someOperation <= anotherOperation
anil rahman
anil rahman
7,786 Points

I've not done swift before but usually when thinking of logic that needs to meet more than one requirement i think of && and ||.

so the question was: we'd like to know if the first operation, someOperation is greater than, equal to or less than anotherOperation.

When it says is greater than or equal to i know it would be >= as a symbol but then it says or less than aswell theres no symbol for greater then equal and less than. So first thing is i can do >= and check that and i can also do a seperate check <= which just makes me think of do check1 >= && do check2 <=.

Michael Friedman
Michael Friedman
495 Points

Thanks very much Mr. Rahman.

May I say to the Treehouse folks... coming from someone with no iOS programming experience and only a couple months on the front end, this exercise is in no way an intuitive linear thought process. I have experience with && || and there was really very little indication that this exercise involved those operators. Given that this is my first few challenges in Swift, I think there could be some better explanation here.

Michael Friedman
Michael Friedman
495 Points

That makes sense. Thank you for the clarification.

anil rahman
anil rahman
7,786 Points

No worries :) I guess they could have mentioned it in a hint somewhere a lot more in your face if its basics.

But the hint did say use the >= kind of operators, i think using that hint you should have kind of seen you would need a >= and a <= which would lead you to a && || situation.