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

Willie Soedewa
Willie Soedewa
3,299 Points

Swift Basic 2.0 Comparison Operator Quiz

I'm having difficulty with this current quiz i'm in. Mainly for the second challenge task which is:

"Great job with the first task! 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."

Can anyone help me where I'm making the mistake? I must not understand the question.

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
let isPerfectMultiple = result == 0
// Task 2 - Enter your code below
someOperation > anotherOperation
someOperation < anotherOperation
someOperation = anotherOperation
let isGreater = someOperation < anotherOperation; false

3 Answers

Anjali Pasupathy
Anjali Pasupathy
28,883 Points

This question is similar to part 2 of the first task.

The first task asked you to see if result == 0 and assign the corresponding Bool to the constant isPerfectMultiple. You performed this task by writing the following code:

let isPerfectMultiple = result == 0

This task is asking you to see if someOperation > anotherOperation and assign the corresponding Bool to the constant named isGreater. The code defining isGreater should mirror the code for isPerfectMultiple in structure.

I hope this helps!

Willie Soedewa
Willie Soedewa
3,299 Points

Hi Anjali,

Thanks for helping out! I've got it figured out haha!

Michael Friedman
Michael Friedman
495 Points

I'm afraid this wasn't enough of a hint for me. Would you be willing to be more forthcoming with some information?

Michael Friedman
Michael Friedman
495 Points

This is still unclear to me.

Anjali Pasupathy
Anjali Pasupathy
28,883 Points

It's alright. I'll try to be more clear.

For task 2, you're suppose to create a constant called isGreater. This constant should be true if someOperation > anotherOperation, and false otherwise.

The expression "someOperation > anotherOperation" evaluates to true if someOperation is greater than anotherOperation, and evaluates to false otherwise.

Thus, you need to assign the constant "isGreater" to the expression "someOperation > anotherOperation":

let isGreater = someOperation > anotherOperation

I hope this helps!

Michael Friedman
Michael Friedman
495 Points

Oh thanks, I got it sorted out on another thread!

Anjali Pasupathy
Anjali Pasupathy
28,883 Points

You're welcome! I'm glad you figured it out! (: