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

Boris Davidovic
Boris Davidovic
1,010 Points

if someone can give me the solution to this one and explain i would be grateful. Operators 2/2

Challenge Task 2 of 2

In this task, we have two math operations. Without computing the values of those operations, we'd like to know if the first operation, someOperation is greater than, equal to or less than anotherOperation.

Use the greater than or equal to operator and assign the Boolean result of the comparison to a constant named isGreater.

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 = 200 % 5
// Task 2 - Enter your code below
let isPerfectMultiple = result == 0

someOperation > anotherOperation
someOperation == anotherOperation
someOperation < anotherOperation
someOperation  anotherOperation

2 Answers

isn't a Swift operator. However >= is a Swift operator and it will do as you'd expect.

The challenge also asked you to store that value in a constant called isGreater and I didn't see you do that anywhere.

Solution:

let isGreater = someOperation >= anotherOperation

I hope this helps :grin:

~Alex

Boris Davidovic
Boris Davidovic
1,010 Points

Hello Alexander, i went through both video guides and checked all kinds of variations to get through this one(checked in xcode like 15 times) so i didnt copy/paste the constant isGreater in this message but im aware of it :)

the one that worries me is that i did the exact same thing like yourself, but with the ≥ mark . Why? cause that mark is used in tutorial video and nobody mentioned the one that you posted in this comment >=

hopefully someone benefits from this example. thank you

Hi Boris,

You're correct, yes. The video does show only the compact character representations of ≥ and ≤ which is unhelpful. Maybe Pasan Premaratne will consider a modification to the video.

Steve.

Boris Davidovic
Boris Davidovic
1,010 Points

Hey Steve, thanks for fast assist. i passed this one and continue to next. Really loving the whole concept of IOS teaching via treehouse . Cya soon .

Boris

Hey Boris - glad you got it sorted.

As in our discussion elsewhere tonight, here's how an @ mention works; Boris Davidovic

That's a better way of getting hold of me and allows me to answer your questions within these Community pages which helps many other students.